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 / June 2007

Tip: Looking for answers? Try searching our database.

Macro that runs only once?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EllenM - 06 Jun 2007 16:18 GMT
Hello, I have a word document containing macros which  run automatically when
I launch the document. Specifically, the macro displays a userform which
prompts the user to enter data that will go into the word file but saves a
copy of this word file with the changes. The original file is untouched. So
far so good.



Here is my dilemma:  I do not want the macro to run each time I open the
copy of the original file.   I found WordBasic.DisableAutoMacros at the
following link but do not know how or where to use it.  Can I use this
command to disable auto-open macros from copies but keep the auto-open macros
enabled in the original file?  Thanks.



http://word.mvps.org/FAQs/InterDev/DisableAutoMacros.htm

Thanks in advance for your help.

Ellen
Jay Freedman - 06 Jun 2007 17:24 GMT
You're misusing Word. The macro should be in a template, not a document, and
it should be named AutoNew. You should then use the File > Open dialog to
make new documents based on the template instead of re-opening the original
and saving as another file.

Signature

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.

> Hello, I have a word document containing macros which  run
> automatically when I launch the document. Specifically, the macro
[quoted text clipped - 13 lines]
>
> Ellen
EllenM - 08 Jun 2007 12:03 GMT
Thanks, Jay, for your reply.  Actually, I  initially started out that way,
using templates. The real trouble I’m having is when I create a document from
the template that has the Auto_Open macros code attached to it.  The macro
does not run. I can only get the macros to self execute when I launch the
file as a Word document instead of the Word template. I can not explain why
launching a .doc file over a .dot would make a difference. The templates
disables the auto_macros when they are launched.



I did find a fix but I don’t really like it. Any suggestions?

> You're misusing Word. The macro should be in a template, not a document, and
> it should be named AutoNew. You should then use the File > Open dialog to
[quoted text clipped - 18 lines]
> >
> > Ellen
Graham Mayor - 08 Jun 2007 12:34 GMT
An AutoOpen macro runs when you *open* a document of template. If you are
*creating new* documents from a template and want a macro to run on
creation, you need an AutoNew macro. If you might reopen the document and
wish the macro to run again you need both macros.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Thanks, Jay, for your reply.  Actually, I  initially started out that
> way, using templates. The real trouble I'm having is when I create a
[quoted text clipped - 36 lines]
>>>
>>> Ellen
EllenM - 08 Jun 2007 16:18 GMT
That did the trick. AutoNew instead of AutoOpen.



Thanks!

> An AutoOpen macro runs when you *open* a document of template. If you are
> *creating new* documents from a template and want a macro to run on
[quoted text clipped - 41 lines]
> >>>
> >>> Ellen
 
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.