Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Nov 2004
    Location
    Newcastle upon Tyne
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    List allocated macros (Word 2000)

    A couple of years ago I spent quite a while creating some macros for a particular template. Then I created a toolbar, allocated the macros to the relevant buttons, and edited the text on the button to reflect the macro function. Amongst other things, this meant that the "Customize" button descriptor no longer reflects the macro name. The thing I *didn't* do was clean up the all the odds and ends in the VBA window. Now I would like to add another function to the macro in one of the toolbar buttons.

    Alas, I no longer know which version of the macro is the one allocated to the button. I realise lesson number one is, clean up your macro code to remove all unwanted variations. However, I would also now like to know (partly out of curiosity) how to get a list of what macros are assigned to any given button/toolbar. At this stage it would be quicker, just to remove the macros one by one and see which lost macro breaks the button - though at least one of them calls another procedure. But now I gotta know: how do I generate that list?

    Philippa

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

    Re: List allocated macros (Word 2000)

    As long as you know the name of the macro being used, you can determine which varriation is being used by seeing wgich templates are loaded that include Oublic vesions of the code.

    If there is a version in the template in which the toolbar lives, it is likely that is the version used.
    Otherwise, it will be a version in the Normal or a globally loaded template.

  3. #3
    New Lounger
    Join Date
    Nov 2004
    Location
    Newcastle upon Tyne
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List allocated macros (Word 2000)

    >>As long as you know the name of the macro being used,<<

    That's the problem - I don't. The Customize button only shows the text on the button and not the name of the macro. It also occurred to me that there should be a way of creating a list of buttons on a toolbar with the names of the commands/macros attached to each one. I couldn't find one, however, and hoped that someone here would know. Should I have put this on the VBA board?

    Philippa

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List allocated macros (Word 2000)

    Say that your button is the 3rd button on a toolbar named MyToolbar. The name of the macro assigned to it is <code>CommandBars("MyToolbar").Controls(3).OnActio n</code>. Activate the Visual Basic Editor (Alt+F11), activate the Immediate window (Ctrl+G), and type

    <code>? CommandBars("MyToolbar").Controls(3).OnAction</code>

    then press Enter. If you want to see a list of all controls on a toolbar and the macros assigned to them, create a macro like this and run it:

    Sub ListToolbar()
    Dim ctl As CommandBarControl
    For Each ctl In CommandBars("MyToolbar").Controls
    Debug.Print ctl.Caption, ctl.OnAction
    Next ctl
    Set ctl = Nothing
    End Sub

    Don't forget to substitute the correct toolbar name.

  5. #5
    New Lounger
    Join Date
    Nov 2004
    Location
    Newcastle upon Tyne
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List allocated macros (Word 2000)

    Thanks, Hans, worked a treat. I don't think I would every have found it on my own, and I'd certainly never have thought of the Immediate window - I barely knew it existed, and didn't know what it was for.

    Philippa

Posting Permissions

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