
Tips.Net > ExcelTips Home > Macros > Macros in Template Files
Summary: People often place macros in template files to perform any number of tasks. This tip describes a situation where the link between a toolbar button and a macro was broken when a new document was created from a template. The problem was corrected by double-checking where the toolbar button pointed when referencing the macro. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)
Subscriber Kay Rock wrote to describe a problem she was having with a template, a macro, and a toolbar button. It seems that Kay created a macro, saved it in the workbook, and assigned the macro to a toolbar button. When she later saved the workbook as a template, the toolbar button no longer worked properly if she deleted the original workbook.
When you create a macro, you have the opportunity to specify exactly where it should be stored. If you store it in a workbook, and then later save the workbook as a template, the macro is still there because the workbook is converted to a template that contains all the original macros stored with the workbook.
The problem is with the toolbar button. When you create a toolbar button and assign a macro to it, Excel remembers where the macro is stored. When the workbook was originally created, the macro was stored in the workbook. This means that the toolbar button "points" to the macro in the workbook. Even after the workbook is saved as a template, the toolbar button still points to the macro in the workbook, not in the template.
To correct this situation, all you need to do is--after you save the workbook as a template--make sure you open the template and reassign macros to the toolbar buttons. These macros should be ones that reside in the template itself, not in any other workbook you have open at the time. You can then save the template and everything should work fine. You can reassign the macros by following these steps:
Tip #2717 applies to Microsoft Excel versions: 97 2000 2002 2003
More Power! Expand your skills and make Excel really sing! It's all possible with macros. The best resource anywhere for macros is ExcelTips: The Macros. Check it out today!
No, not that type of date. If you need to do any types of work with calendar dates, Excel has the tools you need. Learn how to use those tools the easy way. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site