使用微软Office的拼写检查功能,以C# [英] Using MS Office's Spellchecking feature with C#

查看:359
本文介绍了使用微软Office的拼写检查功能,以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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆