+ Reply to Thread
Results 1 to 2 of 2

Which toolbar Button was clicked?

  1. #1
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Which toolbar Button was clicked?

    I am developing a workbook that manages menubars and toolbars so I can easily add macros to shortcut menus, delete buttons on tool bars etc.

    As part of this spreadhseet, i would like to be able to easily assign a particular icon to a button on a toolbar. I have created a temporary toolbar that has 100 buttons with random faces. The buttons are not associated with an OnAction event (yet). What I want to be able to do, is click a button and capture which button was clicked. Once I know which button was clicked, I will know which button to assign to the main toolbar I am working with.

    I had 2 ideas, neither which I know how to get to work.

    1. Assign every button 1 - 100 to the same macro, and try to capture the name or number of the button that was just clicked. I am not aware of an event that will allow me to do this however.
    2. Build a custom macro at the time that I add the button to the toolbar. ie if I add button 24, I call it button24, then create a macro called button24Click() that passes number 24 back to my other code. Trouble is I don't know how to get VBA to create VBA code.

    If anyone can help with how to do either of these, or has any other ideas, I would love to hear from you.

    Matt

  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Talking

    Solved my own problem. I found what I need here http://www.cpearson.com/excel/vbe.htm

    I new I had seen something like this somewhere.

+ 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