Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JZ JZ is offline
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
JZ JZ is offline
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default 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
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
How to remove customized button from toolbar? Eric Excel Discussion (Misc queries) 1 August 6th 09 05:44 AM
Customized Toolbar Macro Buttons MSThinksItKnowsBetter Setting up and Configuration of Excel 8 June 1st 08 09:28 AM
Customized Macro Button Check [email protected] Excel Discussion (Misc queries) 1 August 11th 07 12:23 AM
How do I create a customized toolbar button? Excell 2007 rllngriver Excel Discussion (Misc queries) 6 April 23rd 07 08:04 AM
How can I make the print icon trigger customized macro? Bon Excel Programming 5 December 6th 05 03:36 PM


All times are GMT +1. The time now is 10:16 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"