In that case, your Document_Open() procedure should not contain a
Documents.Open statement -- the document will already be opening --
and instead of a MyDoc object you can just use ActiveDocument:
ActiveDocument.AttachedTemplate = "c:\test.dot"
I will explain my problem. In the past I used documents with macrocode and
when the document was processed I deleted all the vba code (in a dropvbacode
subroutine) with the objects but that's only possible if the checkbox: trust
visual basic source is checked. Our information department gives us each
month another image and then the checkbox is unchecked again with lots of
error messages as a result. Now I want to use a template with code to
support a document with no vba code in it. Thats called by a third doc with
code like this:
testmacro.doc with autoopen which is unaltered:
Sub autoopen()
Documents.Open ("d:\testmacroempty.doc")
ActiveDocument.AttachedTemplate = "d:\testmacro.dot"
End Sub
(where testmacroempty.doc is the document that the users my alter, mail,
open again and again, print etc)
but my problem is that the Document_Open() macro does not fire because the
template is attached AFTER the opening of the testmacroemptydocument.
Our workaround is difficult, we cannot alter general and document templates
(no writing rights) and we use worddocuments with lots of hyperlinks to
other documents with a lot of vba-code. You cannot open a document based on
a tempate by a hyperlink in word, is this right???
Mayby there's a workaround?
Thanks a lot...