Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if some word exists using Word dictionary

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?

like image 831
gtzalik Avatar asked Dec 02 '25 07:12

gtzalik


1 Answers

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.

like image 81
Patrick Hofman Avatar answered Dec 03 '25 20:12

Patrick Hofman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!