View Single Post
 
Old 09-16-2022, 04:07 PM
Cosmo Cosmo is offline Windows Vista Office 2007
Competent Performer
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
This is what I mean.
A global template that contains the UI modifications and any related code, separate from the document template that contains the content and document format/styles.
The global could also hold building blocks that can be used to create content.
I am assuming that your UI modification is done by editing the XML of the template, not through vba on-the-fly editing. (Customize the Office Ribbon (It doesn't take rocket science) by Greg Maxey )

A global template in the Startup folder shares the UI modifications with all other documents / templates but does not insert those mods in others. They can be used.
If this is only to work with certain document templates, those templates could load the Add-In upon creation of a document and then the document template's code could unload the Add-In when the new document is closed.
Yes, the UI is done by editing the XML

Ok, so what you're saying is if i have 5 different document templates, I create the templates without code or the CustomUI, and another template with all of the code and CustomUI for all 5 documents?

Currently, i am using the 'Document_New()' event of the template (in the 'ThisDocument' Microsoft Word Objects space) to run the code to set up the document (shows a userform to collect data, and populates the document).

To move the code to a 'Master' template, I'd need to move this activation to an app event handler "App_NewDocument(ByVal Doc As Document)" event in the Master template, then I'd need to determine which template created the active document, and run the setup function(s) needed for that specific template?

Is this the proper workflow?

Edit: after thinking about this, i might be able to keep all of the code for the setup of the document in the content template, and move the rest of the UI specific code to a separate 'Master' since that's mostly for editing/updating the document once it's created. Theres's a 'New XXXX Document' button to create a new document from the specific template, but that would just need to create the document, and the rest of the code would work as usual.

I very much appreciate your assistance, and patience, with me.
Reply With Quote