Search code examples
c#ms-wordoffice-interop

C# Word Interop - Spell Checking in a Certain Language


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

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?


Solution

  • Found my solution:

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

    Edit after comment

    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;
    

    thanks @Adrianno for all the help!