Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Problem with macros assigned to toolbar buttons

I believe this is usually resolved by having code in the
Workbook_Open event that programmatically creates a
temporary custom toolbar (Temporary parameter set to
True). The macros are also assigned to the buttons at the
same time. Because its status is set to Temporary, when
the workbook is closed it automatically deletes the custom
toolbar. The Workbook_Open event code automatically
creates it again when it is opened. The same holds for
any copy made of the workbook. So the referenced macros
for the toolbar buttons always point to that workbook.

The second method is to create the toolbar and then attach
it to the workbook (Tools|Customize|Toolbars tab|Select
toolbar|Attach option). Then use the Workbook_BeforeClose
event or AutoClose macro to delete the toolbar on close.
When the workbook is subsequently opened and Excel cannot
find the toolbar because it has been deleted then it will
recreate the toolbar according to its status when it was
attached including macro references. This is true for
copies of the workbook also.

An important point is that attached toolbars are not
updated after being attached. So changes made to an
attached toolbar will not take effect. To make changes to
an attached toolbar, unattach it, make the changes and
reattach it.

Regards,
Greg


-----Original Message-----
I have a custom toolbar with macros assigned to the
buttons. The name of the macro assigned to the button

has
the tempalte workbook name referenced to it.

When I create a new workbook from the template, the
workbook reference for the macro changes. If I close the
new workbook (by closing excel), and open either the
template or a previously created woorbook, the workbook
reference of the macro is the last workbook that was
created. When I click on the button, excel opens the

last
workbook created and runs the macro there...not in
the "current" workbook.

Is there a way to omit the workbook reference that
preceeds the macro name where you assign a macor name to

a
button? Is there such a thing as a "local" macro?

Hope this makes sense...my cold medicine is making me

feel
a little loopy.

Thanks in advance.

Rich
.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problem with macros assigned to toolbar buttons

Greg,
Thanks for the advice.
Since I already had an Auto_Close event to turn off the
toolbar visibility, I just changed the *.visibility=false
to *.delete.
Worked like a champ. Again, Thanks.

Rich

-----Original Message-----
I believe this is usually resolved by having code in the
Workbook_Open event that programmatically creates a
temporary custom toolbar (Temporary parameter set to
True). The macros are also assigned to the buttons at

the
same time. Because its status is set to Temporary, when
the workbook is closed it automatically deletes the

custom
toolbar. The Workbook_Open event code automatically
creates it again when it is opened. The same holds for
any copy made of the workbook. So the referenced macros
for the toolbar buttons always point to that workbook.

The second method is to create the toolbar and then

attach
it to the workbook (Tools|Customize|Toolbars tab|Select
toolbar|Attach option). Then use the

Workbook_BeforeClose
event or AutoClose macro to delete the toolbar on close.
When the workbook is subsequently opened and Excel cannot
find the toolbar because it has been deleted then it will
recreate the toolbar according to its status when it was
attached including macro references. This is true for
copies of the workbook also.

An important point is that attached toolbars are not
updated after being attached. So changes made to an
attached toolbar will not take effect. To make changes

to
an attached toolbar, unattach it, make the changes and
reattach it.

Regards,
Greg


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 Custom toolbar problem saving new buttons Karen O Excel Discussion (Misc queries) 6 June 23rd 09 10:42 PM
Assigning Macros to Toolbar buttons JMay Excel Discussion (Misc queries) 1 July 24th 07 07:22 PM
Macro assigned to Toolbar problem JHL Excel Discussion (Misc queries) 2 March 22nd 07 11:44 PM
How can you replicate macros for buttons on the Standard toolbar? Suzi Excel Discussion (Misc queries) 1 February 16th 07 09:53 PM
Why does macros assigned to a toolbar lose its link when saved as Elsa Excel Discussion (Misc queries) 3 October 18th 05 09:48 PM


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