【发布时间】:2012-07-25 23:37:42
【问题描述】:
使用下面的代码,我基本上是逐字检查文档并将正确的分开。我工作,但太慢了,我必须等待 10 多分钟才能写 4 万字。当我打开同一个文档时,Word 会在几秒钟内对其进行检查。我做错了什么?
var application = new Application();
application.Visible = false;
Document document = application.Documents.Open("C:\\Users\\hrzafer\\Desktop\\spellcheck.docx");
// Loop through all words in the document.
int count = document.Words.Count;
IList<string> corrects = new List<string>();
for (int i = 1; i <= count; i++)
{
if (document.Words[i].SpellingErrors.Count == 0)
{
string text = document.Words[i].Text;
corrects.Add(text);
}
}
File.WriteAllLines("corrects.txt", corrects);
application.Quit();
【问题讨论】:
标签: interop ms-word spell-checking