Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Attach custom toolbar to workbook (2003)

    I created a custom toolbar that I want to open when a certain spreadsheet opens. I created the custom toolbar and I thought I attached it to the workbook but when I close the workbook and reopen it, the toolbar doesn't open also. What am I doing wrong....

  2. #2
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Attach custom toolbar to workbook (2003)

    Are you using code that looks like this?:
    Set myButton = Application.CommandBars("Worksheet Menu Bar").Controls.Add

    Also ensure that this code is in the Workbook.Open Event.
    Regards,
    Rudi

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

    Re: Attach custom toolbar to workbook (2003)

    In fact, when you attach a toolbar to a workbook, it will remain when you close the workbook unless you take measures to remove it.

    To attach a toolbar to a workbook:
    - Make sure that the workbook is open and is the active workbook.
    - Select Tools | Customize...
    - Activate the Toolbars tab.
    - Click Attach...
    - Select the custom toolbar you want in the list on the left.
    - Click the Copy >> button.
    - OK your way out.
    - Save the workbook. The toolbar is now stored in the workbook.

    If you want the toolbar to disappear when you close the workbook, you can write a Before Close event procedure in the ThisWorkbook module:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    On Error Resume Next
    Application.CommandBars("MyToolbar").Delete
    End Sub

    You must, of course, substitute the correct name.
    Warning: if you create this event procedure before you have saved the workbook with the attached toolbar, make sure that you attache the toolbar and save the workbook first, before closing the workbook. You only have to do this once.

Posting Permissions

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