1
我試圖從dotnetpearls.com運行一個示例程序,起初該程序根本不起作用。收集的請求的成員不存在,MS Word
顯然我必須以管理員身份運行VS Express 2012,然後才能啓動應用程序對象。之後,下一次出錯時,我會嘗試打印文檔中的文本。錯誤發生在string text = doc.Words[i].Text;
using System;
using Microsoft.Office.Interop.Word;
namespace WordTestProgram
{
class Program
{
static void Main(string[] args)
{
Application app = new Application();
Document doc = app.Documents.Open("C:\\word.doc");
int count = doc.Words.Count;
for (int i = 0; i <= count; i++)
{
string text = doc.Words[i].Text;
Console.WriteLine("Word {0} = {1}",i,text);
}
app.Quit();
}
}
}
我知道一個事實,我試圖將文檔從提取數據,並有3個字,並在其中3位。所以它不是空的。
在此花了一個小時。爲什麼VSTO從1開始收藏?花了這麼長時間,當你在調試期間看本地人時,收藏清楚地從[0]開始。哇。 – RMuesi