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!
> 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
[quoted text clipped - 15 lines]
> >saved in a different location so that when that document is opened to view
> >the infomration or make changes, the macro doesn't run?
Dian D. Chapman, MVP - 31 Oct 2006 19:08 GMT
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
>I created a document that when opened, automatically runs a macro to require
>users to complete four userforms that will automatically populate the Word
[quoted text clipped - 30 lines]
>> >saved in a different location so that when that document is opened to view
>> >the infomration or make changes, the macro doesn't run?