+ Reply to Thread
Results 1 to 5 of 5

How to add button/toolbar to one workbook only when it opens

  1. #1
    Registered User
    Join Date
    03-01-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    57

    How to add button/toolbar to one workbook only when it opens

    Could someone help me by suggesting a code that would initialize and delete a button that runs a certain macro. Right now, I have a button that is on the toolbar and stays there regardless of what excel file I use. It's unecessary and annoying.
    I know that the sub workbook_open and sub workbook_beforeclose have to be used but I'm kinda clueless after that.
    Last edited by EK1; 03-18-2010 at 09:19 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: How to add button/toolbar to one workbook only when it opens

    Hello EK1,

    Here are two macro you can use. One adds a button to the Excel menu bar called "Run Macro". This has ALT+R as the hot key. The second macro removes the button. Each of these will need to be called from the appropriate Workbook event. The button is temporary and should be removed when the workbook closes, but this is Windows. You will need to make some changes to the macro. They are marked with comments in the code. Copy this code to a VBA module.

    Add and Delete Menu Button Macros
    Please Login or Register  to view this content.


    Workbook Event Module Code
    Add this code to the ThisWorkbook module.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    03-01-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: How to add button/toolbar to one workbook only when it opens

    Thanks Leith. Code works like a charm. I modified a few things and moved it to the Formatting bar and it's perfect.

  4. #4
    Registered User
    Join Date
    07-26-2013
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: How to add button/toolbar to one workbook only when it opens

    Hi Eki,

    Could you share your changes to the code? I'd like to know how to move it to another tab and rename the group.

    Thanks

  5. #5
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: How to add button/toolbar to one workbook only when it opens

    This is not possible with VBA and Ribbon. You must use CustomUI.xml part for this.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1