Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

spell check throwing exception

Status
Not open for further replies.

gib99

Programmer
Mar 23, 2012
51
0
0
CA
Hello,

I'm trying to get the English dictionary object MS Word uses and I want to use it to spell check. Here is the code I'm writing to do that:

Code:
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Dictionary EngDict = null;


foreach (Microsoft.Office.Interop.Word.Language l in app.Languages)
{
    if (l.Name.Contains("English (US)"))
    {
        EngDict = l.ActiveSpellingDictionary;
        break;
    }
}

EngDict.LanguageID = Microsoft.Office.Interop.Word.WdLanguageID.wdEnglishUS;
object EngDictObj = EngDict;
bool b = CheckSpelling("hello", EngDictObj);

Here's the CheckSpelling function:

Code:
private bool CheckSpelling(string word, object dict)
{
    Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
    object O = null;

    return app.CheckSpelling(word, ref O, ref O, ref dict, ref O, ref O, ref O, ref O, ref O, ref O, ref O, ref O, ref O);
}

The call to app.CheckSpelling(...) in my CheckSpelling function throws a COMException whose details say "Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)". Can anyone see what I might be doing wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top