Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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, Befo=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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Dynamically creating a toolbar button

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with the Camera Button for creating dynamically updating pic Niceaction Excel Discussion (Misc queries) 0 December 3rd 08 03:56 PM
Repetive Formatting/Creating a Toolbar button rllngriver Excel Discussion (Misc queries) 11 November 21st 07 01:38 PM
Creating a macro that simulates some of the toolbar button Duangruthai New Users to Excel 1 April 22nd 06 12:12 AM
Creating a button on Excel Toolbar Todd Huttenstine[_2_] Excel Programming 2 December 1st 03 11:28 PM


All times are GMT +1. The time now is 06:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"