VBA code in template does not work in document

S

Seamus Conlon

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
 
D

Doug Robbins - Word MVP

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.

--
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
 
S

Seamus Conlon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top