Antonyms of the WordList in excel using vba

sanits591

Active Member
Joined
May 30, 2010
Messages
253
Hi,

I would like to have the antonyms of the word list of (5000 plus words) of Col A, in the columns on the right side.

This i would like to achieve using VBA codes.

Please assist me in doing this, in excel.
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Excel only knows 1 antonym so unless you already have your 5000 in a lookup table you will have to code each of 5000 individually.
 
Upvote 0
Thanks for responding to it. I would be happy enough, if finding out the antonym is done through some vba code in excel, or through some external program or through some website containing the antonyms data.
 
Upvote 0
Sorry, Excel doesn't have a built in list of Antonyms.
You're going to have to do some manual work.

I found quite a few lists with a simple google search.
You'll need to compile those lists into an excel sheet.

Then a fairly simple lookup formula can be used to convert a given word to it's antonym.
 
Upvote 0
Thanks for updating on this front.

Can we link excel to some external program (having antonyms data) or some website to get the same done in MS excel as desired?
 
Upvote 0
I have found a code which works for a specific word "Big" and in MS Word.

Now i am looking for, if the Words are list in Col A in excel, then:
a). Read the words in Col A, then search for the antonym using below code with some modifications done in this code (in MS word).
b). Retrieve these antmoyms displayed in MS word to excel in the Col B to Col (i) as applicable.

Request to help me out.

Code:
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
 
Upvote 0
Forcing me to put on my thinking cap...:cool:


That is actually using Word's Thesaurus....


Try this in a New Module

Highlight a range of cells containing words you want antonyms for.
It will put the antonyms in the columns directly to the right of the range you selected..

Run the macro called test

Code:
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
 
Last edited:
Upvote 0
Left out 2 important lines at the top when I copy/pasted the code...

Should be

Rich (BB 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
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top