How to change an MS Word document's template before opening?

A

alanmurphy

Hi,

Does anybody know how to change an MS Word document's assigned
template, preferably before the document opens? DSOFile.dll can't do
it, and I'm not sure what else that leaves?

Any and all pearls of wisdom welcomed and appreciated,

Cheers,
Al
 
J

Jay Freedman

Hi,

Does anybody know how to change an MS Word document's assigned
template, preferably before the document opens? DSOFile.dll can't do
it, and I'm not sure what else that leaves?

Any and all pearls of wisdom welcomed and appreciated,

Cheers,
Al

It isn't possible to change it without opening the document first.

Once it is open, assign the AttachedTemplate property:

ActiveDocument.AttachedTemplate = "C:\Templates\Letter.dot"
 
T

Tony Jollans

But note that if just the path is changing and the new template name is the
same as the old name, this won't work, and you will need to do it a
different way:

With Application.Dialogs(wdDialogToolsTemplates)
.Template = "C:\Templates\Letter.dot"
.Execute
End With
 
Top