This code supposes to delete all the thesaurus from a specific word when right click on it. For example if you type television and you righ click on it, and go to synonym you will get 4 entries. When running this macro, it suppose to delete the entries. For any reason, when I ran it. I received “run time error 91, object variable or with block variable not set”. The problem is in the for each statement. Keep in mind I found a partial of this code from an article and it supposes to work, but it does not.
Here is the code. How can I solve this problem
Sub Macro20()
Dim Ctrl As CommandBarControl
Dim ThesaurusMenu As CommandBarPopup
Set ThesaurusMenu = CommandBars.ActionControl
For Each Ctrl In ThesaurusMenu.Controls
Ctrl.Delete
Next Ctrl
End Sub
I copy a a portion of this code from an article by Mike Craven in the MSDN titled Word Popups