使用微软Office的拼写检查功能,以C# [英] Using MS Office's Spellchecking feature with C#
问题描述
我想用C#做一个应用程序;它会计算正确的字和错字在文本并显示我来说...有在MS Word功能..所以我怎么能是否可能使用此功能在C#中? (在土耳其语)。
I wanna do a application with C# ; it will count correct words and wrong words in a text and show me it ... there is a feature in MS Word .. So how can i use this feature in C# if its possible ? (in Turkish language).
推荐答案
您可以添加到Microsoft Word X.0对象库的引用。检查出这个信息MSDN文章: http://msdn.microsoft.com/en-us /库/ 15s06t57 (VS.80)的.aspx。
You can add a reference to Microsoft Word x.0 Object Library. Check out this MSDN article for information: http://msdn.microsoft.com/en-us/library/15s06t57(VS.80).aspx.
一旦你已经添加了引用,你应该再能够使用Word.Application对象。它看起来像这样(未测试的代码!)
Once you have added the reference you should then be able to use the Word.Application object. It would look something like this (untested code!!).
using Word;
public void checkspelling(string text)
{
Word.Application app = new Word.Application();
object template=Missing.Value;
object newTemplate=Missing.Value;
object documentType=Missing.Value;
object visible=true;
object optional = Missing.Value;
_Document doc = app.Documents.Add(ref template,
ref newTemplate, ref documentType, ref visible);
doc.Words.First.InsertBefore(text);
Word.ProofreadingErrors errors = doc.SpellingErrors;
ecount = errors.Count;
doc.CheckSpelling( ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional, ref optional,
ref optional);
if (ecount == 0)
{
// no errors
}
else
{
// errros
}
}
这篇关于使用微软Office的拼写检查功能,以C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!