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 / January 2006

Tip: Looking for answers? Try searching our database.

VBA code in template does not work in document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Seamus Conlon - 11 Jan 2006 09:29 GMT
I have created a template that has code in the Document_Open event (in the
ThisDocument object) to fill some combo boxes etc.  I want this code to run
each time I open a document that has been created using the template.  There
are also command buttons on the template that run code to do other things
and these also need to work in any new documents.  However, this does not
happen.  The template is attached to the new document ok and the command
buttons are present but the document_open code does not run nor does the
code for the command buttons.

Any ideas on how to resolve this problem?

Thanks,
Seamus
Doug Robbins - Word MVP - 11 Jan 2006 09:43 GMT
Put the code in a macro named AutoNew() in the template and then use
File>New and select the template when you need to create a document.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> I have created a template that has code in the Document_Open event (in the
> ThisDocument object) to fill some combo boxes etc.  I want this code to
[quoted text clipped - 9 lines]
> Thanks,
> Seamus
Seamus Conlon - 11 Jan 2006 11:08 GMT
Thanks, Doug.  The initial code to set up the comboboxes etc I can
put in the AutoNew() macro and its owrks ok.  But some of the
code will run when a command button is clicked and this does not
work. Is this because that code is not in the new document but in the
attached template?  Could I put code in the AutoNew() macro to
copy the other code into the ThisDocument module in the new
document?

Seamus

> Put the code in a macro named AutoNew() in the template and then use
> File>New and select the template when you need to create a document.
 
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.