sub antonym()
Dim arrayAntonyms As Variant
Dim intLoop As Integer
Set myAntObj = Selection.Range.SynonymInfo
arrayAntonyms = SynonymInfo(Word:="big", _
LanguageID:=wdEnglishUS).AntonymList
For intLoop = 1 To UBound(arrayAntonyms)
MsgBox arrayAntonyms(intLoop)
Next intLoop
End Sub
Sub test()
Dim i As Long
Dim c As Range
Dim sWord As String
Dim arr
For Each c In Selection
sWord = c
If GetMeanings(sWord, arr) Then
For i = LBound(arr) To UBound(arr)
c.Offset(0, i).Value = arr(i)
Next
End If
Next c
Set mObjWord = Nothing 'clears the word object when done
End Sub
Function GetMeanings(myWord As String, vMeanings)
Dim objSynonymInfo As Object
If mObjWord Is Nothing Then
Set mObjWord = CreateObject("word.application")
End If
Set objSynonymInfo = mObjWord.SynonymInfo(myWord)
vMeanings = objSynonymInfo.antonymlist
GetMeanings = UBound(vMeanings) > 0
End Function
Option Explicit
Private mObjWord As Object
Sub Antonyms()
Dim i As Long
Dim c As Range
Dim sWord As String
Dim arr
For Each c In Selection
sWord = c
If GetMeanings(sWord, arr) Then
For i = LBound(arr) To UBound(arr)
c.Offset(0, i).Value = arr(i)
Next
End If
Next c
Set mObjWord = Nothing 'clears the word object when done
End Sub
Function GetMeanings(myWord As String, vMeanings)
Dim objSynonymInfo As Object
If mObjWord Is Nothing Then
Set mObjWord = CreateObject("word.application")
End If
Set objSynonymInfo = mObjWord.SynonymInfo(myWord)
vMeanings = objSynonymInfo.AntonymList
GetMeanings = UBound(vMeanings) > 0
End Function