Reputation: 57
I'm developing a Word 2010 AddIn using C# and VSTO. I wanted to know if I can check some word exists in the Word's dictionary?
I find this var dict = Application.CustomDictionaries.ActiveCustomDictionary;
but I don't know how can I use it to check if some word exists.
Any ideas?
Upvotes: 3
Views: 1949
Reputation: 156978
You can read the dictionary file by hand, and check whether the word exists in the list.
Try this:
string[] words = File.ReadAllLines(Path.Combine(Globals.ThisAddIn.Application.CustomDictionaries[1].Path, Globals.ThisAddIn.Application.CustomDictionaries[1].Name));
bool wordExists = words.Contains("yourWord");
NOTE:
Your example reads the custom dictionary, not the Word internal dictionary. As far as I know it is not possible to read the default dictionary.
Upvotes: 2