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 / March 2008

Tip: Looking for answers? Try searching our database.

Open document and ignoring macros

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ray C - 24 Mar 2008 17:40 GMT
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
Jay Freedman - 24 Mar 2008 20:21 GMT
> I have VBA code that opens a word document using:
>
[quoted text clipped - 7 lines]
>
> 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.

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.

Ray C - 24 Mar 2008 21:20 GMT
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

> > I have VBA code that opens a word document using:
> >
[quoted text clipped - 11 lines]
> outside the WordBasic object, the DisableAutoMacros command. It's documented
> at http://www.word.mvps.org/FAQs/MacrosVBA/WordBasicCommands.htm.
Jay Freedman - 24 Mar 2008 21:33 GMT
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.

> 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
[quoted text clipped - 34 lines]
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
Graham Mayor - 25 Mar 2008 08:52 GMT
And don't forget to turn the automacros back on again afterwards!

Signature

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

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

> Hi Ray,
>
[quoted text clipped - 42 lines]
>>> Email cannot be acknowledged; please post all follow-ups to the
>>> newsgroup so all may benefit.

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.