+ Reply to Thread
Results 1 to 2 of 2

Custom Toolbar Button Problem

  1. #1
    Registered User
    Join Date
    06-16-2005
    Posts
    68

    Custom Toolbar Button Problem

    I've been having a problem with some custom toolbar buttons I've created and I haven't been able to find a cause or solution on the web. I have created a few simple macros to do tasks that Excel doesn't have built-in toolbar buttons for - an example would be a button that fits to one page for printing. This macro (and the others) are saved in an add-in file called Buttons.xla that is added into my Excel.

    The problem is that occassionally (and apparently randomly) these buttons will begin targetting a file other than my .xla file to find the macros. When I click on the button after this occurs, I get an error message that the macro can't be found. When I edit the custom button, the macro will be listed something like this Book1.xls!fit_to_page. If I delete the 'Book1.xls!' portion and save, the button will work fine for a few days, a week or a month before switching back to some random file.

    I know this is confusing, but anyone have any ideas? Thanks for your help - Chad

  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    I had a different but similar issue. I had a file say myMacros v1.xls where that had macros pointing to my custom toolbar. When I upgraded to myMacros v2.xls and distributed it to others, the buttons kept pointing to the v1. Different cause but same problem. I solved this issue by adding an auto_exec macro as follows

    Sub auto_open()
    Application.CommandBars("myToolbar").Visible = True
    Application.CommandBars("myToolbar").Controls("myButton").OnAction = "Macro1"
    End Sub

    The macro reasigns the buttons to the correct macro each time the file is open. Not sure if it will work with an XLA.

    Matt

+ 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