Seems Easy, Attach a Template, but...
Posted on 2004-10-07
Ok, I've slogging through all the entries out there on templates and I can't find one precisely like the problem I'm having...
There are a bunch of documents in a directory that need to use the same code.
I have a template in the SAME directory as all of these documents.
I want that when a document in that directory opens, it attaches the template to itself.
Sounds easy, but...
This directory is being delivered electronically to lots of different people who will put that directory wherever the heck they want to. I have no idea if they use local templates or templates on their server, and do not want to have to care where they keep their templates.
So how do I get it to attach the "MyTemplate.dot" file that's in the same folder as the document itself.
I tried the following code:
Private Sub Document_Open()
.UpdateStylesOnOpen = True
Debug.Print ActiveDocument.Path & "\DEP.dot"
.AttachedTemplate = ActiveDocument.Path & "\DEP.dot"
and get the following error when I open the document:
Microsoft Visual Basic
Run-time error '5947'
Could not change document template.
What am I doing wrong?
250 'cause it's difficult to me!