Discussion:
Stop AutoOpen macro from running
(too old to reply)
DSUK
2005-12-05 15:41:03 UTC
Permalink
Hi, I am having a problem getting Autoopen macros from openeing.

I have a macro in a template that automatically opens documents in a folder,
does some reformatting and saves them, the problem I am having is that some
of the documents have an AutoOpen macro in them that displays a dialog box
and stops everything until you click on OK, I would like to disable the
AutoOpen macro in the documents that are being opened so I can reformat the
enture batch.

I have the following code but it seams to stop the original macro from
running as well as, please can anyone point me in the right direction.

With Application
.AutomationSecurity = msoAutomationSecurityForceDisable
.Documents.Open MyPath + "\" + CurrDoc, False
.AutomationSecurity = msoAutomationSecurityLow
End With

Thanks
David
Jay Freedman
2005-12-05 16:01:21 UTC
Permalink
Use the WordBasic.DisableAutoMacros method.
WordBasic.DisableAutoMacros 1 'Disables auto macros
WordBasic.DisableAutoMacros 0 'Enables auto macros

See http://word.mvps.org/FAQs/MacrosVBA/WordBasicCommands.htm
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Post by DSUK
Hi, I am having a problem getting Autoopen macros from openeing.
I have a macro in a template that automatically opens documents in a
folder, does some reformatting and saves them, the problem I am
having is that some of the documents have an AutoOpen macro in them
that displays a dialog box and stops everything until you click on
OK, I would like to disable the AutoOpen macro in the documents that
are being opened so I can reformat the enture batch.
I have the following code but it seams to stop the original macro from
running as well as, please can anyone point me in the right direction.
With Application
.AutomationSecurity = msoAutomationSecurityForceDisable
.Documents.Open MyPath + "\" + CurrDoc, False
.AutomationSecurity = msoAutomationSecurityLow
End With
Thanks
David
DSUK
2005-12-05 16:22:02 UTC
Permalink
Thank you that has worked a treat
Post by Jay Freedman
Use the WordBasic.DisableAutoMacros method.
WordBasic.DisableAutoMacros 1 'Disables auto macros
WordBasic.DisableAutoMacros 0 'Enables auto macros
See http://word.mvps.org/FAQs/MacrosVBA/WordBasicCommands.htm
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Post by DSUK
Hi, I am having a problem getting Autoopen macros from openeing.
I have a macro in a template that automatically opens documents in a
folder, does some reformatting and saves them, the problem I am
having is that some of the documents have an AutoOpen macro in them
that displays a dialog box and stops everything until you click on
OK, I would like to disable the AutoOpen macro in the documents that
are being opened so I can reformat the enture batch.
I have the following code but it seams to stop the original macro from
running as well as, please can anyone point me in the right direction.
With Application
.AutomationSecurity = msoAutomationSecurityForceDisable
.Documents.Open MyPath + "\" + CurrDoc, False
.AutomationSecurity = msoAutomationSecurityLow
End With
Thanks
David
Helmut Weber
2005-12-05 16:11:52 UTC
Permalink
Hi David,

try:

Wordbasic.DisableAutoMacros
--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Continue reading on narkive:
Loading...