Open document and ignoring macros

R

Ray C

I have VBA code that opens a word document using:

objDocument.Open("C:\...")

however, some documents have macros that auto start when the document opens,
how can I tell Word to open the document and ignoe or disable the auto macros?

Thanks in advance

Ray
 
J

Jay Freedman

Ray said:
I have VBA code that opens a word document using:

objDocument.Open("C:\...")

however, some documents have macros that auto start when the document
opens, how can I tell Word to open the document and ignoe or disable
the auto macros?

Thanks in advance

Ray

You need one of the few old WordBasic commands that aren't available in VBA
outside the WordBasic object, the DisableAutoMacros command. It's documented
at http://www.word.mvps.org/FAQs/MacrosVBA/WordBasicCommands.htm.

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

Ray C

Thanks Jay, but I had already found this solution and somehow it's still not
working. Where exactly am I supposed to place the following line?:

WordBasic.DisableAutoMacros 1

1) Immediately after I call the Open method on my document object?
2) Before?
3) Is this WordBasic object global? because I open a Word object in my code,
then I leave it in memory while I open and close document objects. At the end
I close my Word object.

Thanks in advance.
Ray
 
J

Jay Freedman

Hi Ray,

You should put that line before the Open call -- afterward is too late, as
any AutoXX macros would already have run then.

The WordBasic object is global, being a member of the Word.Application
object.
 
G

Graham Mayor

And don't forget to turn the automacros back on again afterwards!

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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