Search code examples
c#.netvb.netms-wordoffice-interop

.NET Word interop, spell check, add word to dictionary


I'm using Visual Basic, Windows Forms and Word (interop) to provide spell checking for a customer.

The customer asked if it would be possible to add words to the spell checking dictionary, as names are being marked as spelling errors.

I've seen that there's a "ResetIgnoreAll" method which clears a list of words to ignore while spell checking, but that list is temporary.

I have a way of meeting the customers wishes, but I'm not 100% happy with it. Is there any way of adding words to the Word dictionary via their interop stuff?


Solution

  • A possible solution would be the following:

    1. Add all names to a text file (which each name in a separate row)
    2. Store the text file ("MyCustomDictionary.dic") somewhere on the client PC, e.g. in the user's profile or together with your application.
    3. Add the file as a custom spelling dictionary in Word. This can be either done via the UI (File > Options > Proofing > Custom Dictionaries...) or programmatically via

      Application.CustomDictionaries.Add <full filename of custom dictionary>