Disable/remove template macros during SaveAs?

E

Ed

I open a template with macros, add information, then SaveAs a new document.
Now, when the new document opens, I not only get the "Macros, anyone?"
dialog box, I have to remember to disable them or the Auto_Open macro fires
and screws my document up! Is it possible to slip something into the code
that will remove or at least disable the macros in the new document?

Thanks.
Ed
 
J

Jezebel

The macros aren't normally in the document; they are in the template. An
Auto_Open macro in a template runs every time a document based on the
template is opened. That's what Auto_Open is for. If you want the code to
run only for new documents, use Auto_New.
 
E

Ed

Okay, let's see if I can dig myself out of this one. This isn't a .dot
template - it's a .doc document that I'm *calling* a "template" because it's
what I use to do the other stuff on. In ThisDocument for my "template" is
an Auto_Open macro. This "template" doc is opened by code from an Excel
macro; the Auto_Open code takes stuff copied from Excel, pastes it into the
"template" and manipulates it, then does a SaveAs to create a new doc.

I'm guessing my first mistake was not using a *PROPER* template. But I
think I would still need the Auto_Open event, because I'm doing this from
Excel and I don't want to have to go into Word in the middle of an Excel
macro to execute the other code. As you can probably tell, I'm not real up
on all of this - any help you can give is appreciated.

Ed
 
D

Doug Robbins - Word MVP

Hi Ed,

You most definitely should save your "template" document as a proper
Template. And rename your macro to AutoNew
In Excel, you would then use Documents.Add("yourpropertemplate") which will
create a new document from your Template and cause an AutoNew macro in that
template to run. When you save the document, it will not contain the macros
and as the macro is now named AutoNew, it will not run when the document is
re-opened.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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