C#调用Word拼写检查功能
来源:互联网 发布:java类构造函数 编辑:程序博客网 时间:2024/05/01 21:16
public string ChkSpelling(string word)
{
System.Type wordType = System.Type.GetTypeFromProgID("Word.Application");
object wd = System.Activator.CreateInstance(wordType);
StringBuilder sb = new StringBuilder();
object start = 0;
object end = 0;
object missing = System.Type.Missing;
object IgnoreUppercase = true;
object AlwaysSuggest = true;
((ApplicationClass)wd).Visible = false;
((ApplicationClass)wd).Documents.Add(ref missing, ref missing, ref missing, ref missing);
((ApplicationClass)wd).ActiveDocument.Range(ref start, ref end).Text = word;
((ApplicationClass)wd).Options.CheckGrammarWithSpelling = true;
((ApplicationClass)wd).Options.SuggestSpellingCorrections = true;
((ApplicationClass)wd).CheckSpelling(word, ref IgnoreUppercase, ref AlwaysSuggest, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
if (((ApplicationClass)wd).ActiveDocument.SpellingErrors.Count > 0)
{
this.lblStatus.Text = "Error!!!";
foreach (ApplicationClass Suggestion in ((ApplicationClass)wd).GetSpellingSuggestions(word, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing))
{
sb.AppendLine(Suggestion.Name);
}
}
else
{
this.lblStatus.Text = "Right!!!";
}
((ApplicationClass)wd).ActiveDocument.Close(ref missing, ref missing, ref missing);
((ApplicationClass)wd).Quit(ref missing, ref missing, ref missing);
Marshal.ReleaseComObject(((ApplicationClass)wd));
wd = null;
return sb.ToString();
}
- C#调用Word拼写检查功能
- 拼写检查C#类库调用示例
- C# word 拼写 语法
- word 2007 取消拼写/语法检查
- 怎么取消word 的拼写检查怎么取消word 的拼写检查
- 使用Eclipse的单词拼写检查功能
- MindManager中的拼写检查功能怎么用
- 拼写检查
- 拼写检查
- 使用ASP和Word进行服务器端拼写检查
- Word如何取消自动拼写检查、自动句首字母大写
- Word 2010 取消拼写/语法检查,隐藏红线/绿线
- Word 2010 取消拼写/语法检查,隐藏红线/绿线
- Word 关闭拼写检查 (去掉Word中拼写检查的所有红色和绿色的浪线)
- 在.NET应用程序中添加拼写和语法检查功能
- 对TexStudio配置拼写和语法检查LanguageTool功能
- C# Attribute调用检查
- AS SpellCheck拼写检查
- C++内存泄漏检测
- liferay 中文参数乱码问题(二)
- 常用的javascript的event对象
- Cstring用法
- fck_editor 不采用正则表达式实现插入任意自定义图片标签的解决方法
- C#调用Word拼写检查功能
- IIS服务器组建一览
- JavaScript中的this、with的用法
- 一个公用的js验证
- enqueue等待事件优化一例
- TomCat中JDBC配置
- subclipse
- 用VB取得操作系统安装的时间
- JSP环境搭建