我正在編寫使用Word.dll進行拼寫檢查的c#代碼。我用下面的網站參考: http://www.codeproject.com/Articles/2469/SpellCheck-net-spell-checking-parsing-using-Cc中的拼寫檢查#
但我得到一個錯誤:「類型或命名空間名稱‘字’找不到(是否缺少using指令或程序集引用?)」
,我使用的代碼是:
SpellCheck word = new SpellCheck();
bool status = false;
string s = "youes";
Console.WriteLine("Checking for word : " + s);
// check to see if the word is not correct
// return the bool (true|false)
status = word.CheckSpelling(s);
if (status == false)
{
Console.WriteLine("This word is misspelled : " + s);
Console.WriteLine("Here are some suggestions");
Console.WriteLine("-------------------------");
foreach(string suggestion in word.GetSpellingSuggestions(s))
{
System.Console.WriteLine(suggestion);
}
}
else if (status == true)
{
Console.WriteLine("This word is correct : " + s);
}
我只是想知道我怎樣才能使它發揮作用?
'下添加refernce到Micorsoft.Office.Interop.Word;'這是你的代碼的頂部? – Bolu 2012-02-27 09:47:38