Storing Macros in Templates

by Allen Wyatt
(last updated December 14, 2019)

1

Tony has a question about the differences between macro storage in Word and Excel. In Word, macros can be stored in a document's template and you can attach a template to a particular document. Thus, Tony is able to maintain just one template and edit it to add new automation features to documents he may have created years ago. Tony wonders if there is a way to do the same in Excel so that all of his co-workers can utilize the macros stored in an Excel template on a network drive.

The short answer is that there is no way to do what you are describing. The reason is that there is an intrinsic difference between how templates are used in the two programs. In Word, a template is actively attached to a document and whenever a document is opened, the template attached to that document is also opened. If the template has changed since the last time the document was opened (for instance, if the template was updated to contain new macros), then those changes are immediately available within that document.

In Excel, templates aren't like that. True, you can create macro-enabled templates (XLTM files), and then create workbooks based on those templates. The macros in the template should end up as part of the workbook you create based on that template. But that is as far as it goes; there is no "active link" between a document and a template. If you later update the template with new macros, any workbooks previously created based on that template are not affected.

If you want to make constantly updated macros available to co-workers, there are three ways to go about doing so in the Excel environment. First, you can rely on the Personal.xlsb file. Any macros in this special workbook are available to the user because it opens whenever Excel is being used. You could set up a system to constantly update the Personal.xlsb workbook on every co-worker's system. The downside to this is that it is a pain to constantly update.

The second approach is to create a special macro-enabled workbook on a network drive that is accessible to all your co-workers. You might give it a special name, such as OurCompanyMacros.xlsm, and use it to do nothing except store your company macros. Teach all your co-workers to open this workbook whenever they use Excel, and then they will have access to any macros in the workbook. This is more manageable than the approach that relies on Personal.xlsb because you only need to update the macros in the one workbook and then all users can access them.

The third approach is to create a company add-in that contains your macros. How you create an add-in is too detailed for this tip, but you can find additional information in these ExcelTips:

https://excelribbon.tips.net/T008528
https://excelribbon.tips.net/T008529

The add-in could be stored on a network drive, and then users could install that add-in on their system and use all the macros it contains. When installing a network add-in, users are automatically given the option to copy the add-in to their local drive. If a user chooses to copy the add-in, that will defeat the ability to update the add-in and have the co-workers have access to the updated macros. The way around that is to develop some "check" in your macros to always make sure the current local add-in is the latest version. If it is not, your macro could prompt the user to perform whatever update process you might develop to make sure the add-in is up to date.

You can get just about as fancy as you want in developing and deploying add-ins. If you want more information about add-ins than you probably wanted, you might refer to this Microsoft website:

https://docs.microsoft.com/en-us/office/dev/add-ins/excel/

The bottom line is that because of the differences in how templates are conceived and implemented in Excel when compared to Word, it can be quite a bit harder to make sure that users of specific workbooks have access to updated macros for those workbooks.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13712) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Discovering the RGB Value of a Custom Text Color

Word allows you to easily change the color of the text in your document. If you get a document from someone else, you may ...

Discover More

Adding Page Borders to a Printout

Need a full-page border on your Excel printouts? It's not as easy to get one as you might wish. There are a few ways you ...

Discover More

Keyboard Shortcuts for Zooming

For whatever reason, Microsoft has never seen fit to provide built-in keyboard shortcuts for zooming in and out. Here are ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Progression Indicator in a Macro

When your macro is humming along, minding its own business, a user watching the screen may not see any activity and ...

Discover More

Selecting a Range of Cells Relative to the Current Cell

When processing information in a macro, you often need to select different cells relative to the currently selected ...

Discover More

Creating a Directory in a Macro

One of the things you can do with macros is to work with disk files. As you do so, you may have a need to create a new ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 5?

2019-12-17 11:49:35

Christian SOMMERHUBER

Hi, I'm no longer working in an environment with a network server, but I could imagine that following options may work as well:
- in the Personal.xlsb you can in Visual basic tell to link under "Tools -References..." the file stored on the server.
- I think the even better approach would be to store an AddIn on the server and to load the AddIn directly from there. I don't think that all used AddIns have to be in the default folder for AddIns.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.