Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Menu names in macros (W97 VBA)

    Hi all

    There have recently been a few threads including using automacros (autonew, autoopen, autoclose, etc) and menu commands such as filesave, fileopen, etc, to alter the functions of these menu items, and I have two questions:
    <UL><LI>Where could one find a list of the names of these commands? Not just the menu commands, but the items on their dialogs, eg in FilePrint, how to set the focus to the 'current page' button when you don't know what MS have called it (I know there are probably workarounds for most of these individually, but I was hoping for a source of the names for reference so I wouldn't have to fiddle around everytime I wanted to use them)

    <LI>What would the equivalent be in the VBE? If I set FileSave to do something on saving, it works fine in the main Word screen, but in the VBE it completely ignores it so it must be called something else, I presume?[/list]Any suggestions would be much appreciated!
    Beryl M


  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Menu names in macros (W97 VBA)

    Beryl,

    There is a wealth of information available from the Object Browser in theVBE. Select View, Object Browser, and in the search box enter dialog for example, and you should get a listing of Properties, Methods etc for all dialogs available for the libraries that are active, (VBA, Office, Word etc.). If you highlight any one and press F1 you should get detailed help on using that object.

    If you have difficulties with anything there, you can then post specific questions.

    Good luck.

    Andrew C

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

    Re: Menu names in macros (W97 VBA)

    Beryl,

    In addition to looking in the Object Browser as Andrew has suggested, also take a look at the VBA Help topic called "Built-in dialog box argument lists".

    Gary

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Menu names in macros (W97 VBA)

    Thanks, Gary - that one was brilliant! I'd looked through the help before trying to find lists of these sorts of commands and not succeeded because I didn't know what Word called it!

    Thanks also, Andrew - I have tried to get to grips with the Object Browser before but I'm not very confident with it yet ...
    Beryl M


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

    Re: Menu names in macros (W97 VBA)

    Beryl,

    Glad that helped.
    To expand a little on the other part of your question:

    In Word you can get a list of the names of the built-in Word commands by showing the Macros dialog and selecting "Word commands" from the Macros In: dropdown. You can then intercept any of these commands (as you know) by creating your own macro with the identical name - your code then runs instead of the built-in command when that command is 'called' from the user interface.

    A couple of points about that:
    When you run code from the VBE Editor, by default it's acting upon Word, not on the VB Editor environment. So "FileSave" is going to execute a FileSave in Word, not a FileSave in the VB Editor.

    The designers of Word VBA made it very nice for us by giving us the list of Word commands and making it so these can be intercepted by running code in the VB Editor.
    But no such convenience was provided for running code that acts upon the VB Editor. Some means have been provided for running code in the VB Editor, that acts upon the VB Editor, but the implementation is pretty thin.

    Look up "VBE" and "VBProject" in the Word VBA Help and you'll see some info on basic objects relating to the VBE, that you can work with from Word VBA.
    For access to a bigger range of objects, properties and methods for working with the VB Editor, you need to set a reference in your project to the VB Extensibility Library (has slightly different names depending on version of Word.)

    Once you've got a reference set to this in your project, you can get more info on what this library makes available by: Open the Object Browser (press F2). In the Project Library dropdown at the upper left, select VBIDE - this will make visible all the Classes and Members of the VBIDE library.
    To find out more information about any of these, right-click on one, select Help, and the Help topic for that element should appear.

    I'm not aware of any good reference for working with this stuff; what you can do is limited. The best thing is just to take some time and play around with it. There have also been a few threads here that dealt with this topic.

    Hope this helps,
    Gary

Posting Permissions

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