Forum Discussion

D_Watson2185's avatar
D_Watson2185
Copper Contributor
Apr 07, 2025
Solved

attach a common code template document via a template document

(I suspect this has come up before, but I came up empty searching. Wrong keywords?) TL;DR: how can I have a .dotx template that creates new documents with their AttachedTemplate set to a different ....
  • Charles_Kenyon's avatar
    Charles_Kenyon
    Apr 09, 2025

    If your template is loaded as a global template, its AutoOpen will never run.

    Give it a different name and call it from the templates you want to use the code. Otherwise it just sits there in the background.

    If you give it parameters , i.e. Sub MyCode(a,b) it will not show up in the macro listings available from the user interface but will be available to call from other macros. Application Run MyCode. The parameters could be used, but need not be when calling it. You can get specific as to project and module in calling it as well to avoid confusion over the name.

    I routinely have over twenty template add-ins loaded.

    I have my Ribbon template which contains a lot of code to be shared/used by my form document templates. They use the code but it does not reside in the document templates.

    I am a lawyer, not a programmer. In programming language, I think this is called running subroutines.

Resources