Word VBA - how to remove to a Template?

My users will open a new document from a .dotm template. Having run a small procedure on opening, the document then needs to break its connection to this template.

1. How do I remove the reference to that template please?

2. Similarly, I then need to attach another template (AddIn) that has the code to run against this (newly created) document.

Any help or direction will be welcome.
Thanks
hindersalivaAsked:
Who is Participating?
 
GrahamSkanConnect With a Mentor RetiredCommented:
You can change the template with this code
ActiveDocument.AttachedTemplate = strTemplatePath & "\" & strTemplateFile

Open in new window

To 'remove' the template, you can either specify the Normal template, or use an empty string
ActiveDocument.AttachedTemplate = ""

Open in new window

Either will set the template to Normal, because there must be an attached template.
0
 
GrahamSkanRetiredCommented:
You can change the attached template via the 'Template and Add-ins' dialogue which can be opened with the 'Document Template' button the on the Developer tab.
0
 
hindersalivaAuthor Commented:
Sorry Graham. I should have said  .... how can I remove the reference programatically.
0
 
hindersalivaAuthor Commented:
Thanks Graham. Exactly what I was looking for.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.