Here’s a fun trick for all you VBA grammar enthusiasts out there. All 6 of you.
There exists something called a SynonymInfo Object. It lets you access things like definitions, synonyms, antonyms, and parts of speech in Word. Cool beans, right?
You get at these by calling on different properties of the SynonymInfo Object. The PartOfSpeech Property will return an array of integers on whatever word is plugged in. Yes, you read that right. Integers. Those numbers correspond to a particular part of speech.
0 = Adjective
1 = Noun
2 = Adverb
3 = Verb
4 = Pronoun
5 = Conjunction
6 = Preposition
7 = Interjection
8 = Idiom
9 = Other
Keep in mind, lots of words have multiple meanings. Those meanings will each have their own part of speech. This is why the result comes back as an array—to account for different definitions. You can access those with the MeaningList property.
A Very Simple Script
This was the easiest implantation I could think of. It just pops the meanings and their parts of speech into a message box. That’s plugged into a macro that’ll run on whatever word you happen to have highlighted.
Sub PartOfSpeech() If Selection.Range.SynonymInfo.MeaningCount 0 Then For i = 1 To UBound(Selection.Range.SynonymInfo.MeaningList) MsgBox (Selection.Range.SynonymInfo.MeaningList(i)) MsgBox (Selection.Range.SynonymInfo.PartOfSpeechList(i)) Next i End If End Sub
Here’s the result.
More complex scripts integrating parts of speech coming soon.