Results 1 to 13 of 13
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run time error 91 (Word 2000)

    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

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Run time error 91 (Word 2000)

    According to the online help,
    <hr>ActionControl Property

    Returns the CommandBarControl object whose OnAction property is set to the running procedure. If the running procedure was not initiated by a command bar control, this property returns Nothing. Read-only.<hr>
    As I (vaguely) understand this, the procedure needs to be invoked from the Thesauraus menu itself in order for the Set command to successfully attach the ThesaurusMenu variable to the Thesaurus menu. Did the original article give instructions for how to do that?

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run time error 91 (Word 2000)

    The original article did not give any instruction on how to clear it.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Run time error 91 (Word 2000)

    Okay, I might be looking at a different article. This one was for Word 97 and is posted on the WOPR site: How to Build a Popup Style or Thesaurus Menu in Word 97, By Mike Craven. The code you posted was part of a custom right-click thesaurus menu, not the built-in function. So I don't know if you can hook the old code up to the new menu; it's not obvious how you would do that.

    That said, what are you trying to do?

  5. #5
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run time error 91 (Word 2000)

    This is the same article you are looking at. The reason I am referring to it, because I want to solve a complex problem. Here is what I want to do. I don

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Run time error 91 (Word 2000)

    It's still unclear from your description, whether you are wanting to delete words from a custom popup menu (which you have previously created programatically) or whether you are trying to delete words from a built-in popup menu.

    If the latter, there's probably no practical way to do that, and if you are running that partial bit of code against a built-in menu, that definitely will cause an error message.

    If the former (you're working with a custom popup all the way) then it should be possible to do.

    Gary

  7. #7
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run time error 91 (Word 2000)

    Thank you very much for all of the posts. I thought it was going to be possible.

  8. #8
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run time error 91 (Word 2000)

    I also understand that editing the .lex file is not possible. It is also proprietary. Am I correct?

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Run time error 91 (Word 2000)

    Option 1: Using Word's spelling features, offer suggestions from Custom dictionary only, not Main dictionary.

    I do not see any way to do this within the options that Microsoft provides. I also do not see any way to use VBA to filter the list, because the SpellingSuggestion object does not indicate its source (main or custom, etc.) I also could not figure out how to drain all the words out of Word's main dictionary even if I wanted to. I also could not figure out how to get rid of the suggestions from the right-click menu (see graphic) so I could replace them with my own list. (Probably there is a way to do this by identifying its ID and using VBA to get rid of it.)

    The code from the Thesaurus macro does not edit the Word 2000 popup, it is part of a system for creating your own list, so that approach is a dead end.

    Option 2: Build or buy a custom spelling system.

    Although this would cost you time or money, it has a better chance of giving you tailored results. But...I think you would lose the red wavy underlines, so perhaps the trade-off is not worth it?
    Attached Images Attached Images

  10. #10
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Run time error 91 (Word 2000)

    I don't know enough about the topic to answer authoritatively, so before I stick my foot in my mouth any further <img src=/S/hushmouth.gif border=0 alt=hushmouth width=16 height=16>, I'll rely on Jefferson's more thoroughly researched advice.

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run time error 91 (Word 2000)

    One can modify built-in menus any which way but loose.

    But one has to look at each menu to see if word will be obstinate and restore items you have deleted/modified.

    When I have need to modify a built-in menu, I just add the items at the end.

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run time error 91 (Word 2000)

    I investigated doing this a few years ago.
    At that time you needed a license/permission from MSFT and a license/permission from the party that developed the dictionary engine.

    You need to contact MSFT's Permisions group.
    I think they are at http://www.microsoft.com/permission/.

  13. #13
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run time error 91 (Word 2000)

    Howard, it looks like you said the built in menu could be edited or changed, but how? You also stated that I could get permission from Microsoft to edit the .lex file. I will be looking to that. As far as I know, it seems like the .lex file is not 100% owned by Microsoft. If you try to open it in text mode, you can see that it is copyrighted by another company. Here is the text I get from the header.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •