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

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SandiK - 31 Oct 2006 00:13 GMT
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?
Jay Freedman - 31 Oct 2006 04:18 GMT
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        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>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?
Dian D. Chapman, MVP - 31 Oct 2006 04:34 GMT
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 

>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?
SandiK - 31 Oct 2006 15:56 GMT
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?

Rate this thread:






 
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.