Word Property Example

This example returns a list of synonyms for the first meaning of the third word in the active document.

Set mySynObj = ActiveDocument.Words(3).SynonymInfo
SList = mySynObj.SynonymList(1)
For i = 1 To UBound(SList)
    Msgbox "A synonym for " & mySynObj.Word & " is " & SList(i)
Next i

This example checks to make sure that the word or phrase that was looked up isn't empty. If it's not, the example returns a list of synonyms for the first meaning of the word or phrase.

Set mySynObj = Selection.Range.SynonymInfo
If mySynObj.Word = "" Then
    Msgbox "Please select a word or phrase"
Else
    SList = mySynObj.SynonymList(1)
    For i = 1 To UBound(SList)
        Msgbox "A synonym for " & mySynObj.Word & " is " & SList(i)
    Next i
End If