Hello - I am trying to generate antonyms in Excel 365. Imagine in cells A1:A15 that I have 15 words. In B1:B15 I would like to see antonyms. I copied the code below from another thread on this site, but it doesn't seem to work, getting hung up on: Set mObjWord = CreateObject("word.application"). Does anyone have thoughts on this? Very much appreciated.
VBA Code:
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