Share via


Creating an Application-Specific Template or Add-in That Acts as a Code Library

If you do not have Microsoft® Visual Basic® or if you do not want to create a DLL, you can create an application-specific template or add-in that contains reusable code for that application.

For example, if you have a set of procedures that you call regularly from code in Word, you can create a template that contains these procedures and set a reference to it from any Microsoft® Word VBA project that must use those procedures. To set a reference to a template (or any file that contains a VBA project), click References on the Tools menu, and use the Browse button to locate the template file.

Note that simply loading a global template in the Templates and Add-ins dialog box does not make it possible for you to call the code that the template contains, except through a command bar control. You must set a reference to the template to call code in the template, even if the template is already loaded.

This solution makes it possible for you to keep application-specific code in an application-specific template, which does not have to be registered in the Windows registry, so it might be an easier solution to implement than a DLL. However, application-specific templates are larger than most DLLs and take longer to load, so your application might be somewhat slower.

See Also

Building Reusable Code Libraries | Creating a DLL that Acts as a Code Library | Sharing Code with the Code Librarian