Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Customized toolbar button trigger macro in a different file
I wrote a macro and assigned it to a button in myToolbar. My goal is to let
people to create their file based on this one and click the button to run the macro. First I saved it as a xls file, then I copy/paste and rename to create a new one. After I open the new one and click the button in the toolbar, it triggered the macro in the original xls file. Not so surprising because the button is associated with the subroutine in the original file. Then I saved it as a xlt file and use File New to create a xls file using the template I jsut created. The new workbook was automatically named as myTest1 assuming the template file name was myTest.xlt. This time when I click the button it DID trigger the macro in the file myTest1 as expected. However I want to give this file a meaningful name. If I save it with another name, the button will not work anymore, similar to the first scenario it pointed to the subroutine in myTest1, which may not even exist if I didn't save it. So I guess it boils down to this: How to make customized button associate with the macro in the newly create file, not the template/seed file? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Customized toolbar button trigger macro in a different file
Your life will become much simpler if you include code to create the toolbar
when the workbook is opened and include code to destroy the toolbar when the workbook is closed. For additions to the worksheet menu bar, I really like the way John Walkenbach does it in his menumaker workbook: http://j-walk.com/ss/excel/tips/tip53.htm Here's how I do it when I want a toolbar: http://www.contextures.com/xlToolbar02.html (from Debra Dalgleish's site) JZ wrote: I wrote a macro and assigned it to a button in myToolbar. My goal is to let people to create their file based on this one and click the button to run the macro. First I saved it as a xls file, then I copy/paste and rename to create a new one. After I open the new one and click the button in the toolbar, it triggered the macro in the original xls file. Not so surprising because the button is associated with the subroutine in the original file. Then I saved it as a xlt file and use File New to create a xls file using the template I jsut created. The new workbook was automatically named as myTest1 assuming the template file name was myTest.xlt. This time when I click the button it DID trigger the macro in the file myTest1 as expected. However I want to give this file a meaningful name. If I save it with another name, the button will not work anymore, similar to the first scenario it pointed to the subroutine in myTest1, which may not even exist if I didn't save it. So I guess it boils down to this: How to make customized button associate with the macro in the newly create file, not the template/seed file? -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Customized toolbar button trigger macro in a different file
Excellent answer! Thanks you very much Dave.
"Dave Peterson" wrote: Your life will become much simpler if you include code to create the toolbar when the workbook is opened and include code to destroy the toolbar when the workbook is closed. For additions to the worksheet menu bar, I really like the way John Walkenbach does it in his menumaker workbook: http://j-walk.com/ss/excel/tips/tip53.htm Here's how I do it when I want a toolbar: http://www.contextures.com/xlToolbar02.html (from Debra Dalgleish's site) JZ wrote: I wrote a macro and assigned it to a button in myToolbar. My goal is to let people to create their file based on this one and click the button to run the macro. First I saved it as a xls file, then I copy/paste and rename to create a new one. After I open the new one and click the button in the toolbar, it triggered the macro in the original xls file. Not so surprising because the button is associated with the subroutine in the original file. Then I saved it as a xlt file and use File New to create a xls file using the template I jsut created. The new workbook was automatically named as myTest1 assuming the template file name was myTest.xlt. This time when I click the button it DID trigger the macro in the file myTest1 as expected. However I want to give this file a meaningful name. If I save it with another name, the button will not work anymore, similar to the first scenario it pointed to the subroutine in myTest1, which may not even exist if I didn't save it. So I guess it boils down to this: How to make customized button associate with the macro in the newly create file, not the template/seed file? -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Customized toolbar button trigger macro in a different file
That was no help!
"JZ" wrote: I wrote a macro and assigned it to a button in myToolbar. My goal is to let people to create their file based on this one and click the button to run the macro. First I saved it as a xls file, then I copy/paste and rename to create a new one. After I open the new one and click the button in the toolbar, it triggered the macro in the original xls file. Not so surprising because the button is associated with the subroutine in the original file. Then I saved it as a xlt file and use File New to create a xls file using the template I jsut created. The new workbook was automatically named as myTest1 assuming the template file name was myTest.xlt. This time when I click the button it DID trigger the macro in the file myTest1 as expected. However I want to give this file a meaningful name. If I save it with another name, the button will not work anymore, similar to the first scenario it pointed to the subroutine in myTest1, which may not even exist if I didn't save it. So I guess it boils down to this: How to make customized button associate with the macro in the newly create file, not the template/seed file? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to remove customized button from toolbar? | Excel Discussion (Misc queries) | |||
Customized Toolbar Macro Buttons | Setting up and Configuration of Excel | |||
Customized Macro Button Check | Excel Discussion (Misc queries) | |||
How do I create a customized toolbar button? Excell 2007 | Excel Discussion (Misc queries) | |||
How can I make the print icon trigger customized macro? | Excel Programming |