Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    remove toolbar button (Word 2000/3)

    I have a toolbar with macros that are activated by buttons.
    How would I go about writing code that would remove the button from the toolbar after the user has clicked the button?
    Regards

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: remove toolbar button (Word 2000/3)

    You can manipulate buttons on toolbars via the Application.CommandBars collection.
    If you know the name of the Toolbar and of the button then this is fairly simple
    <code>Application.CommandBars("My Toolbar").Controls("My &Button").Delete</code>
    You would include this code somewhere in the macro that is called when the button is clicked.

    Depending on why you are deleting the button it may be easier to change its Visible or Enabled property to False, this would make it easier to reinstate the button when you need it again.

    StuartR

  3. #3
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: remove toolbar button (Word 2000/3)

    I agree with Stuart concerning using Visible or Enabled instead of deleting the button. In addition to his reply: whatever you use, this changes the commandbar and makes the container of the toolbar "dirty". Causing a messagebox to appear asking if you want to save this container. To avoid this, put a line of code immediately after the Delete/Visible/Enable line:

    NormalTemplate.Saved = True
    or
    ActiveDocument.AttachedTemplate.Saved = True

    depending where you store the toolbar.

Posting Permissions

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