Results 1 to 4 of 4
  1. #1
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Toolbar close event? (Word 2002 SP-2)

    Another day, another toolbar question...

    Is there a way to trigger a macro when the user closes a toolbar (perhaps something along the lines of the QueryClose event, but for the CommandBar object, rather than a UserForm) -- assuming the user closes the macro using the View menu or clicking the built-in Close button?

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

    Re: Toolbar close event? (Word 2002 SP-2)

    The CommandBars object has an On Update event, but it fires very frequently - it occurs each time something changes in the document that might affect the state of a visible command bar or command bar control. For example, each time the user changes the selection in the document, the On Update event occurs. The event procedure has no arguments indicating what has happened, so it is not very convenient to use. The CommandBar object has no exposed events at all.

    In short, I do not know how to do what you want.

  3. #3
    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: Toolbar close event? (Word 2002 SP-2)

    I'm attaching a sample document illustrating the use of OnUpdate (VBA modules included). I didn't instrument the procedure in the class module to count the number of times the procedure runs. (That would be interesting), but you can decide for yourself whether the performance overhead is too much to use it.

  4. #4
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Toolbar close event? (Word 2002 SP-2)

    Thanks to you and Hans for the responses. I'd already concluded I probably didn't want to mess with the collection's OnUpdate event. In the particular case at hand I simply wanted to reset a couple of static variables by way of clean-up when the toolbar was closed. I've added a Close button to the toolbar (FaceId 1019, for the buttonfacespotters in the audience), and if it gets closed some other way, the heck with it.

Posting Permissions

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