Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoOpen() from a document and from its template

Status
Not open for further replies.

filipne

MIS
Feb 3, 2008
5
Hi,

I noticed that whenever there is an AutoOpen() function in both a MS Word document and in its template, only the one in the document executes when the document is open.

Subsequently if AutoOpen() exists in the template only it is executed from there.

Is it possible to have both execute without making an explicit call to the template's version of AutoOpen() form the Document's version of it ?

Thanks!
 
Totally agree with Tony. AutoOpen is from the old days. yes, it can still work, but the modern usage is Document_Open.

Regarding templates, use Document_New. This is the procedure that executes when the template is used to generate (clone) a new document.

That being said, there IS a hierarchy of execution.

I noticed that whenever there is an AutoOpen() function in both a MS Word document and in its template, only the one in the document executes when the document is open.

Correct. And this is as it should be. If you open a document (made from a template), then AutoOpen in the document fires. Why would the template AutoOpen fire? The template is not being opened.
Is it possible to have both execute without making an explicit call to the template's version of AutoOpen() form the Document's version of it ?
The document does not have a version of it. The template AutoOpen applies...to the template. The document has no "knowledge" about it.

So yes, if you need the instructions in the template AutoOpen to execute, you either have to:

a) explicitly call to it
b) include those instructions in a procedure in the document.

Frankly, AutoOpen in a template file is, for the most part (IMO), pointless.

It depends on what you are trying to do, but, for the most part, if you need something to happen in a new document, then put those instructions in the Document_New event procedure in the template.



Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top