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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
GrahamSkanRetiredCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hindersalivaAuthor Commented:
Thanks Graham. Exactly what I was looking for.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.