C#Word Interop-某种语言的拼写检查 [英] C# Word Interop - Spell Checking in a Certain Language

查看:121
本文介绍了C#Word Interop-某种语言的拼写检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的客户,我需要强制使用某种语言进行拼写检查.

For a customer of mine I need to force the spell checking in a certain language.

我浏览了MSDN文档,发现在活动文档中调用CheckSpelling()方法时,它将调用拼写检查.此方法具有用于自定义词典的参数.

I have explored the MSDN documentation and found that when calling the CheckSpelling() method in the active document, it will invoke the spelling check. This method has parameters for custom dictionaries.

我的问题是我找不到关于那些字典或如何使用它们的任何东西.

My problem is that I can't find anything about those dictionaries or how to use them.

当然,仍然有另一种方式可以做到这一点.

Also there is still the possibility that there is of course another way to do this.

有人能朝着正确的方向推动我吗?

Can anybody boost me in the right direction?

推荐答案

找到了我的解决方案:

foreach (Range range in activeDocument.Words)
{
    range.LanguageID = WdLanguageID.wdFrenchLuxembourg;
}

评论后编辑

由于我的activedocument在变量中,所以我似乎失去了静态Range属性.通过执行以下操作,我发现了一项工作. (lan是我保存WdLanguageId的变量)

Since my activedocument is in a variable I seem to lose the static Range property. I found a work arround by doing the following. (lan is my variable where i keep my WdLanguageId)

object start = activeDocument.Content.Start;
object end = activeDocument.Content.End;

activeDocument.Range(ref start, ref end).LanguageID = lan;

感谢@Adrianno的所有帮助!

thanks @Adrianno for all the help!

这篇关于C#Word Interop-某种语言的拼写检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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