I have atemplate with New Document and Open Document events. I intend
distributing the template to allow users to create documents from it (works
fine). I also want the created documents to run the DocOpen event when they
are re-opened, but that doesn't work even if the template is installed. It
only runs when the template file is opened.
I have been trying a WithEvents class module, but that doesn't seem to run
from the child documents either. I have the class module in the template
project. Is this the right place? Can I even use this approach?
AndyE
Anne P. - 10 Jun 2005 19:54 GMT
In the VB Editor, double-click This Document in your template. Add the
following code:
Private Sub Document_New()
'your code here
End Sub
Private Sub Document_Open()
'your code here
End Sub
Whenever a document that was created from your template is opened, any code
put under Document_Open will run.
Anne P.
>I have atemplate with New Document and Open Document events. I intend
> distributing the template to allow users to create documents from it
[quoted text clipped - 9 lines]
>
> AndyE
AndyE - 13 Jun 2005 23:56 GMT
Anne,
This is what I tried first off. The Document_Open coe doesn't run in
documents that were created under the template.

Signature
AndyE
> In the VB Editor, double-click This Document in your template. Add the
> following code:
[quoted text clipped - 25 lines]
> >
> > AndyE
Jezebel - 11 Jun 2005 00:17 GMT
If you want to use the WithEvents approach, you need to --
a) put the event code in a class module, that contains a module-level
WithEvents declaration, and
b) instantiate an instance of the class module when Word starts, typically
using an AutoExec function.
>I have atemplate with New Document and Open Document events. I intend
> distributing the template to allow users to create documents from it
[quoted text clipped - 9 lines]
>
> AndyE
AndyE - 13 Jun 2005 23:58 GMT
Thanks Jezebel. I was missing the AutoExec function. Where should that be
stored? In the template?

Signature
AndyE
> If you want to use the WithEvents approach, you need to --
>
[quoted text clipped - 17 lines]
> >
> > AndyE