使用下面的代码基本上我正在逐字检查文档并分离正确的文档。我工作,但太慢了,我必须等待 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();