I created a Word file "test.word" that was saved in a C directory. I would now like to execute a template on this explicit Word file using the VBA function, and using the inserted button macro which is already set up.
What should the macro look like for this? I've tried a lot, either I have to create a completely new file or the command takes the template directly ... but not the "test.word" file.
Document.add creates a new Word file. Document.open uses the template as a file. Document.AttachedTemplate runtime error 4198.
Is my project even possible?
CodePudding user response:
To set the template of a new file:
Documents.Add Template:="[FULL PATH TO TEMPLATE FILE]"
To set the template of an existing Document object:
documentObject.AttachedTemplate = "[FULL PATH TO TEMPLATE FILE]"
For more on AttachedTemplate, please see https://docs.microsoft.com/sv-se/office/vba/api/word.document.attachedtemplate
