R
Runt
Dear Whoever,
I'm trying to write a macro which will identify the antonym of a given
word, but I've struck a problem.
Before identifying the antonym I have to identify which meaning of the
word is required (the word 'go' has 8 meanings - each having a
different opposite meaning or no opposite meaning at all).
I am able to select the correct meaning of the word and assign it the
appropriate number in the MeaningList. However, the MeaningList number
does not correspond with the AntonymList number (while there might be
8 meanings for a word there might only be 4 antonyms for the same
word). So the 7th meaning of the word 'go' might correspond with the
4th Antonym of 'go'.
Is it possible to identify the antonym of a given meaning of a given
word using VBA. The Word Thesaurus is certainly able to.
I hope I've made myself clear. If not, here is the (rather messy) code
I'm working on.
Thanks in advance,
Chris
Sub antonymFind()
Set myAntObj = Selection.Range.SynonymInfo
If myAntObj.Found = True Then
relList = myAntObj.RelatedWordList
If UBound(relList) <> 0 Then
word2 = relList(1)
Set myAntObj = SynonymInfo(word2)
End If
Else
MsgBox "Sorry. No antonyms were found for the word '" &
myAntObj.Word & "'"
End
End If
Alistfound = myAntObj.Found
If Alistfound = False Then
End If
MCount = myAntObj.MeaningCount
If MCount < 2 Then
i = 1
GoTo runmacro
End If
MsgBox "'" & myAntObj.Word & "' has " & MCount & " meanings"
For i = 1 To MCount
Mlist = myAntObj.MeaningList
Answer = MsgBox("Is it a synonym of '" & Mlist(i) & "'",
vbYesNo, "What does the word mean?")
Select Case Answer
Case vbYes
'Put the code here that runs in response to Yes
GoTo runmacro
Case vbNo
'Put the code here that runs in response to No
If i = MCount Then
MsgBox "There are no more recorded meanings for the
word '" & myAntObj.Word & "'"
End
End If
End Select
Next i
runmacro:
Alist = myAntObj.AntonymList
If UBound(Alist) <> 0 Then
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.TypeParagraph
Selection.Font.Bold = False
Selection.TypeText Text:="Which word in the text is opposite in
meaning to: "
Selection.TypeParagraph
Selection.Font.Bold = True
Selection.TypeText Text:=Alist(i)
Else
MsgBox "Sorry. No antonyms were found for the word '" &
myAntObj.Word & "'"
End If
End Sub
I'm trying to write a macro which will identify the antonym of a given
word, but I've struck a problem.
Before identifying the antonym I have to identify which meaning of the
word is required (the word 'go' has 8 meanings - each having a
different opposite meaning or no opposite meaning at all).
I am able to select the correct meaning of the word and assign it the
appropriate number in the MeaningList. However, the MeaningList number
does not correspond with the AntonymList number (while there might be
8 meanings for a word there might only be 4 antonyms for the same
word). So the 7th meaning of the word 'go' might correspond with the
4th Antonym of 'go'.
Is it possible to identify the antonym of a given meaning of a given
word using VBA. The Word Thesaurus is certainly able to.
I hope I've made myself clear. If not, here is the (rather messy) code
I'm working on.
Thanks in advance,
Chris
Sub antonymFind()
Set myAntObj = Selection.Range.SynonymInfo
If myAntObj.Found = True Then
relList = myAntObj.RelatedWordList
If UBound(relList) <> 0 Then
word2 = relList(1)
Set myAntObj = SynonymInfo(word2)
End If
Else
MsgBox "Sorry. No antonyms were found for the word '" &
myAntObj.Word & "'"
End
End If
Alistfound = myAntObj.Found
If Alistfound = False Then
End If
MCount = myAntObj.MeaningCount
If MCount < 2 Then
i = 1
GoTo runmacro
End If
MsgBox "'" & myAntObj.Word & "' has " & MCount & " meanings"
For i = 1 To MCount
Mlist = myAntObj.MeaningList
Answer = MsgBox("Is it a synonym of '" & Mlist(i) & "'",
vbYesNo, "What does the word mean?")
Select Case Answer
Case vbYes
'Put the code here that runs in response to Yes
GoTo runmacro
Case vbNo
'Put the code here that runs in response to No
If i = MCount Then
MsgBox "There are no more recorded meanings for the
word '" & myAntObj.Word & "'"
End
End If
End Select
Next i
runmacro:
Alist = myAntObj.AntonymList
If UBound(Alist) <> 0 Then
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.TypeParagraph
Selection.Font.Bold = False
Selection.TypeText Text:="Which word in the text is opposite in
meaning to: "
Selection.TypeParagraph
Selection.Font.Bold = True
Selection.TypeText Text:=Alist(i)
Else
MsgBox "Sorry. No antonyms were found for the word '" &
myAntObj.Word & "'"
End If
End Sub