How to disable macro after saved so it doesn't run when reopened?

S

SandiK

How do I disable the auto open macro after the document has been executed and
saved in a different location so that when that document is opened to view
the infomration or make changes, the macro doesn't run?
 
J

Jay Freedman

Don't name it AutoOpen if you don't want it to run every time you open
the document.

If it should run only when the document is first created from the
template, name the macro AutoNew.

See http://www.word.mvps.org/FAQs/MacrosVBA/DocumentEvents.htm for
more info.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
D

Dian D. Chapman, MVP

I don't quite know if I'm answering your question as you need since I
don't understand the second part of what you're asking...but to
disable Auto macros...hold down the SHIFT key for the ENTIRE time the
document is opening.

Hope that helps. If not, please provide more specific information.

Dian D. Chapman
Technical Consultant, Microsoft MVP
MOS Certified, Editor/TechTrax

Free MS Tutorials: http://www.mousetrax.com/techtrax
Free Word eBook: http://www.mousetrax.com/books.html
Optimize your business docs: http://www.mousetrax.com/consulting
Learn VBA the easy way: http://www.mousetrax.com/techcourses.html
 
S

SandiK

I created a document that when opened, automatically runs a macro to require
users to complete four userforms that will automatically populate the Word
document. The problem we are having now is that when the document is
completed and saved, then later opened if one correction or change needs to
be made the user has to go through the entire macro again. We would like the
macro to run only on open from the base document. I had used the template
format first, but the department didn't want the staff to open it wrong and
actually use the template itself and not a new document from the template.
So, i used the AutoOpen macro which works great; however, it would be better
if I could somehow have it disable after the file-save-as prompt in vba at
the end of execution. I am working with Word 2003. Any assistance would be
great!

Thanks!
 
D

Dian D. Chapman, MVP

Okay, in that case what you really want is to create the master
template and put the macro in the ThisDocument module under the NEW
event. So the macro will be called ThisDocument_New, versus AutoOpen.

Within the ThisDocument module (which is the new way to use Auto
macros...the old "Auto" named macros are more for legacy purposes),
you have a few events listed in the drop down within that module (to
the right). One is New and one is Open.

If you put your opening code in the NEW event...then it'll only run
when the user creates a new document from that master template.

Once the doc is created and saved...since nothing is in the OPEN
event, it won't fire the macro again.

Also do check out the article Jay referenced.

Dian D. Chapman
Technical Consultant, Microsoft MVP
MOS Certified, Editor/TechTrax

Free MS Tutorials: http://www.mousetrax.com/techtrax
Free Word eBook: http://www.mousetrax.com/books.html
Optimize your business docs: http://www.mousetrax.com/consulting
Learn VBA the easy way: http://www.mousetrax.com/techcourses.html
 

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