• Run time error 91 (Word 2000)

    Author
    Topic
    #370193

    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

    Viewing 0 reply threads
    Author
    Replies
    • #584977

      According to the online help,[indent]


      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.


      [/indent]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?

      • #584986

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

        • #584991

          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?

          • #585064

            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

            • #585082

              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

            • #585116

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

            • #585132

              I don’t know enough about the topic to answer authoritatively, so before I stick my foot in my mouth any further hushmouth, I’ll rely on Jefferson’s more thoroughly researched advice.

            • #585152

              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/%5B/url%5D.

            • #585183

              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.

            • #585151

              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.

            • #585106

              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?

            • #585115

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

    Viewing 0 reply threads
    Reply To: Run time error 91 (Word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: