Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Is a Class Module the answer?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AndyE - 10 Jun 2005 17:43 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.