+ Reply to Thread
Results 1 to 2 of 2

Dynamically creating a toolbar button

  1. #1
    Gregory Kip
    Guest

    Dynamically creating a toolbar button

    Hello,

    I am trying to create a toolbar button, paste an icon on it, and assign
    it a macro -- all at run time.

    Here is what I tried.
    Insert->Picture->From File: ~/Desktop/whatever.bmp
    Tools->Macro->Record New Macro: OK.
    Selected the foo.bmp image with the mouse
    Hit Ctrl-c to copy the image to the clipboard
    On the toolbar, right-clicked, ->Customize
    In the Categories field, selected Macros
    From the Commands field, dragged the Custom Button with smiley to the
    toolbar
    Selected the new button on the toolbar
    Clicked Modify Selection
    Changed the name to "&Show All Names"
    Clicked Paste Button Image
    Clicked Assign A Macro: Selected my Show_All_Names macro
    Tools->Macro->Stop Recording


    Here is the code it recorded, without comments:

    Sub Macro1()
    ActiveSheet.Shapes("Picture 1").Select
    Selection.Copy
    Application.CommandBars("Standard").Controls.Add Type:=msoControlButton,
    ID _
    :=2950, Before:=31
    End Sub

    If I run Macro1() again, a new button is created, but no macro is assigned,
    and the button shows a smiley face, not whatever.bmp. Clearly those steps
    weren't recorded. And though I've searched through the Object Browser, I
    haven't found a way to do it.

    Can anyone out there think of a way to do this? Can I programmatically
    manipulate the drop-down menus? If I have to manipulate keystrokes, I will.

    Thanks in advance,
    Gregory Kip

    Sorry about the false email address. I dislike spam. Please respond to the
    newsgroup.




  2. #2
    Gregory Kip
    Guest

    Re: Dynamically creating a toolbar button

    That should be:
    "Selected the whatever.bmp image with the mouse."



+ 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