但是,如果您在 Document 实例上调用 CheckSpelling,它将如文档中所述,如果有一个或多个,则显示拼写对话框找到拼写错误的单词(假设您在构建 Word Application 实例期间,将 Visible 属性分配给 true - 否则,它将等待在后台输入导致应用程序冻结").I am writing a spell check application in C# using word.dll (the Word Interop API).I want to check which spellings are incorrect and accordingly get suggestions for the incorrect words.I got a sample code from the net and I cannot understand the parameters for the following command:Microsoft.Office.Interop.Word._Application.GetSpellingSuggestions (string, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object)I would just like to know what do all the ref objects imply? I want to know their meaning. 解决方案 I worked with this the other day and thought I would like to share my findings and add a bit to the already given answers.You ask:The short answer to this is - look in the documentation.To show you how the GetSpellingSuggestions method can be used in a more complete context, I have included a sample program in the following. Please note that you can change the desired proofing language using the language variable. The code goes as follows:using System;using Microsoft.Office.Interop.Word;namespace WordStack{ public class Program { private static void Main() { // Create a new Word application instance (and keep it invisible) var wordApplication = new Application() { Visible = false }; // A document must be loaded var myDocument = wordApplication.Documents.Open(@"C:...myDoc.docx"); // Set the language var language = wordApplication.Languages[WdLanguageID.wdEnglishUS]; // Set the filename of the custom dictionary // -- Based on: // http://support.microsoft.com/kb/292108 // http://www.delphigroups.info/2/c2/261707.html const string custDict = "custom.dic"; // Get the spelling suggestions var suggestions = wordApplication.GetSpellingSuggestions("overfloww", custDict, MainDictionary: language.Name); // Print each suggestion to the console foreach (SpellingSuggestion spellingSuggestion in suggestions) Console.WriteLine("Suggested replacement: {0}", spellingSuggestion.Name); Console.ReadLine(); wordApplication.Quit(); } }}... which give me the following three suggestions: overflow, overflows, and overflown.The given sample has been implemented using .NET 4.5 and version 15 of the Word Interop API (Office 2013).Please notice that the given sample also solves your comment to one of the already given answers, saying:Personally, I have not experienced that behavior (neither with the GetSpellingSuggestions nor the CheckSpelling methods available on the Application instance).However, if you invoke CheckSpelling on a Document instance, it will, as covered in the documentation, display the Spelling dialog if one or more misspelled words are found (given that you, during construction of the Word Application instance, assigned the Visible property to true - otherwise, it will await input in the background causing the application to "freeze"). 这篇关于使用 Word Interop 在 C# 中进行拼写检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!