【发布时间】:2017-06-21 03:31:26
【问题描述】:
我正在为 word 编写一个插件,在下面的代码中,我将文件中的所有单词放入字典中。
`
Dictionary<string, string> motRap = new Dictionary<string, string>();
Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
Document document = application.Documents.Open("monfichiertxt.docx");
// Loop through all words in the document.
int count = document.Words.Count;
for (int i = 1; i <= count; i++)
{
// Write the word.
string text = document.Words[i].Text;
//motRapport.Add(text);
motRap.Add(text, "blabla");
}
// Close word.
application.Quit();
我想要当前正在运行的 docx 的文件名,而不是写“monfichiertxt.docx”。
有人可以帮我吗 谢谢。
【问题讨论】:
标签: c# ms-word vsto add-in docx