Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Menu Arrays (XP)

    Greetings. I have been searching through the forums and haven't found a similar question, so here goes.

    I have implemented a custom built toolbar, one of the controls is a msoControlPopup which has 5 msoControlButtons on it, each of these activates a seperate sub of code. Using the .OnAction property I set each of these msoControlButtons to subs 'temp_1' to 'temp_5' respectively. Each of these buttons is used to open a different document, so in each of the 'temp_x' subs i call another procedure passing the name of the document to be opened to it. Does this make sense?

    In Visual Basic I know you can create ( and hence reference ) menu items as control arrays.

    I was wondering if there was a similar way of doing this in WORD VBA as it would be better coding to just have the one subroutine that the 5 control buttons all call, and somehow pass their ID into it, which could then be used to open the correct document. For example, I could store the document name in the Tag property, and then use that.

    I hope this makes sense, and am almost sure that the answer is no, but I thought I would post anyhow, just in case <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>
    Thanks,

    pmatz

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

    Re: Menu Arrays (XP)

    The Tag is a good idea. You can set all items to run the same macro, and retrieve the tag in the macro using

    CommandBars.ActionControl.Tag

    ActionControl returns the CommandBarControl that runs the code. Very simple example:

    Sub TestAction()
    MsgBox "You clicked the button with tag " & CommandBars.ActionControl.Tag
    End Sub

  3. #3
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Menu Arrays (XP)

    That is superb, and makes my code much more refined. The Commandbars.ActionControl is very , very helpful.

    Cheers
    Thanks,

    pmatz

Posting Permissions

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