![]() |
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. |
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. |
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. |
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. |
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. |
All times are GMT +1. The time now is 08:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com