Forum Discussion
Separating program from data in a VBA application
- Oct 11, 2020
In Microsoft Word, you can store VBA code intended for a single document in that document.
If you want code to be available to a class of documents, you store the code in a template (.dotm) and create documents from that template (or if the document already exists, attach - i.e. connect - the template to the document). You can update the template and the updated code will be available to all documents associated with the template. The code will not be stored in the associated documents themselves.
If you want code to be available to all documents, you can store it in a global template aka add-in. By default, each Word user has a macro template Normal.dotm, but you can create others. When you update the template, the modified code will be available to all documents.
You might create an add-in (.xlam) to store the macros. When you change the code, you only need to send the user the new version of the add-in with instructions on where to copy it.
See for example How to Create and Use an Excel Add-in for more info.