How to replace with a new template to a document

B

BJ

Here is my code:

Set thisDoc = Application.ActiveDocument
Set myTemp = thisDoc.AttachedTemplate

If myTemp.Path <> "C:\MyWordTemplate" Then
With thisDoc
.AttachedTemplate = "C:\MyWordTemplate\TestTemplate.dot"
.Save
End With
End If

I received the following message:

Word cannot attach a document to a protected template.

Thank you for any help.
 
G

Graham Mayor

As the error message indicates, if the template you are trying to attach is
a locked form template, the function will fail. Wouldn't it be simpler to
create new documents from the template?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

BJ

The template is not protected. the template is used by all the departments.
user first download it from our intranet, and the template will be saved to a
common folder on their C drive. but somehow some users copied the template to
their favoite folder. So once we updated the template and notified user to
download the updated one, their templates didn't get updated since they saved
to somewhere else.

I tried to add some code to attache the correct template and received the
error message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top