Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Assign Sub to Custom Button

How can I assign a particular Sub to a button that I create
programmatically? In other words, I have created a subroutine that will
create a custom toolbar and buttons on the user's computer. It will created
(if it does not exist) or be made visible when a particular workbook is
opened and hidden when the workbook closes. How do I assign other
subroutines to those custom buttons through the programming? None of the
buttons will be for existing Excel functions.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Assign Sub to Custom Button

Hi
the easiest thing would be:
- delete the old button (enclosed in 'on error resume next / on error
goto 0' statements to prevent error if it does not exist)
- rebuild the menu and add your new function/sub to it

--
Regards
Frank Kabel
Frankfurt, Germany

"Aggie94" schrieb im Newsbeitrag
...
How can I assign a particular Sub to a button that I create
programmatically? In other words, I have created a subroutine that

will
create a custom toolbar and buttons on the user's computer. It will

created
(if it does not exist) or be made visible when a particular workbook

is
opened and hidden when the workbook closes. How do I assign other
subroutines to those custom buttons through the programming? None of

the
buttons will be for existing Excel functions.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Assign Sub to Custom Button

.OnAction = "MyMacro"

use the onaction property of the button.

http://msdn.microsoft.com/library/techart/ofcmdbar.htm



--
Regards,
Tom Ogilvy


"Aggie94" wrote in message
...
How can I assign a particular Sub to a button that I create
programmatically? In other words, I have created a subroutine that will
create a custom toolbar and buttons on the user's computer. It will

created
(if it does not exist) or be made visible when a particular workbook is
opened and hidden when the workbook closes. How do I assign other
subroutines to those custom buttons through the programming? None of the
buttons will be for existing Excel functions.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Assign Sub to Custom Button

I tried the OnAction property but it runs the associated sub at the time the
toolbar is built. After that it does nothing.

I am printing out the topic you provided but I have not had a chance to look
through it. I'm sure the answer is there but I may be back.

Thanks for the help.

"Tom Ogilvy" wrote in message
...
.OnAction = "MyMacro"

use the onaction property of the button.

http://msdn.microsoft.com/library/techart/ofcmdbar.htm



--
Regards,
Tom Ogilvy


"Aggie94" wrote in message
...
How can I assign a particular Sub to a button that I create
programmatically? In other words, I have created a subroutine that will
create a custom toolbar and buttons on the user's computer. It will

created
(if it does not exist) or be made visible when a particular workbook is
opened and hidden when the workbook closes. How do I assign other
subroutines to those custom buttons through the programming? None of

the
buttons will be for existing Excel functions.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Assign Sub to Custom Button

You asked:

How do I assign other

subroutines to those custom buttons through the programming?

In that vein, I would create the toolbar each time the workbook was opened
or if it is in an addin, each time excel was opened and the addin loaded.
Then you should know it is always pointing to the correct file to run the
macro.

--
Regards,
Tom Ogilvy

"Aggie94" wrote in message
...
I tried the OnAction property but it runs the associated sub at the time

the
toolbar is built. After that it does nothing.

I am printing out the topic you provided but I have not had a chance to

look
through it. I'm sure the answer is there but I may be back.

Thanks for the help.

"Tom Ogilvy" wrote in message
...
.OnAction = "MyMacro"

use the onaction property of the button.

http://msdn.microsoft.com/library/techart/ofcmdbar.htm



--
Regards,
Tom Ogilvy


"Aggie94" wrote in message
...
How can I assign a particular Sub to a button that I create
programmatically? In other words, I have created a subroutine that

will
create a custom toolbar and buttons on the user's computer. It will

created
(if it does not exist) or be made visible when a particular workbook

is
opened and hidden when the workbook closes. How do I assign other
subroutines to those custom buttons through the programming? None of

the
buttons will be for existing Excel functions.








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
Excel 2003 - assign macro to custom toolbar button Candace Excel Discussion (Misc queries) 1 August 10th 09 12:14 PM
Assign Add-In to Custom Toolbar Button Microsoft Office 2007 britt_04 Excel Discussion (Misc queries) 1 October 13th 08 09:57 PM
2003 - 2007 custom macro and custom button restore. Scott Sornberger Excel Discussion (Misc queries) 11 May 23rd 08 02:41 PM
How Do I Assign a Toolbar Button to a Custom Number Format I creat FuadsCurse Excel Discussion (Misc queries) 3 March 27th 06 09:44 PM
How can I assign a symbol to a button (like the $ button) NickW Excel Discussion (Misc queries) 2 September 6th 05 02:45 PM


All times are GMT +1. The time now is 10:21 PM.

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

About Us

"It's about Microsoft Excel"