Re: Word automation bypasses macro security

From: Jonathan West (jwest_at_mvps.org)
Date: 02/25/05


Date: Fri, 25 Feb 2005 00:50:40 -0000

Precede that line of code with this

WordApp.WordBasic.DisableAutoMacros(1)

To turn auto macros on again at the end of the routine, use this

WordApp.WordBasic.DisableAutoMacros(0)

-- 
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
<ksopher@comcast.net> wrote in message 
news:1109292316.421251.33100@f14g2000cwb.googlegroups.com...
> Version: Word 2000, 2002
> OS: Win2K, WinXP
>
> With the macro security set to High, when I try to open a document
> containing an AutoOpen macro it does not run and I am propmted with the
> usual message about macros not being enabled.  This is what I want.
>
> I have a VB.NET application that automates Word using a COM wrapper.
> When I open the same document programmatically on the same computers
> the AutoOpen macro runs.  I do not want this to happen.  There is going
> to be no user interaction, so holding the shift key and other such
> tricks aren't realistic options. I do not have control over the
> documents being processed, they are being submitted for processing by
> external users.
>
> The code I'm using is pretty rock-solid.  It's been in production for 2
> years. The line executed where the file is open is:
>
> OpenDoc = WordApp.Documents.Open(FileName:=aFileName, ReadOnly:=True)
>
> Due to security concerns I need to ensure that the auto macros don't
> run when the file is opened via automation on the server.
>
> What do I need to do to have the Word automation respect the Word macro
> security settings?  I've created the necessary Registry keys in HKLC so
> that they override anything at the HKCU or application level, but this
> isn't stopping it through automation.  I've scoured the WROX Word 2000
> VBA Programmer's Reference, MSDN online, Google Groups, etc., but can't
> find anything.  Alternatively, I'd be happy to just remove the AutoOpen
> macros (and AutoExec, AutoNew), but it seems like a catch-22 - I can't
> delete them unless I open the document first, but by then the macros
> have run.
>
> TIA - Keith
> 


Relevant Pages

  • Re: Word automation bypasses macro security
    ... > With the macro security set to High, when I try to open a document> containing an AutoOpen macro it does not run and I am propmted with the> usual message about macros not being enabled. ... > Due to security concerns I need to ensure that the auto macros don't> run when the file is opened via automation on the server. ...
    (microsoft.public.office.developer.automation)
  • Re: Big Trouble at the little relief hut
    ... This is essentially automation even if it initiated ... You can still write macros that automate a process. ... Even addons can implement some form of automation, ... reagents whenever they tank to a reagent vendor. ...
    (alt.games.warcraft)
  • Re: Big Trouble at the little relief hut
    ...  Some behaviors may be considered unfair by the community ... This is essentially automation even if it initiated ... They don't fully restrict being able to automate via macros or even ...  Even addons can implement some form of automation, ...
    (alt.games.warcraft)
  • Re: Photo field in Form
    ... Adding Automation to your Word forms. ... Learn more VBA (macros) to automate your forms. ... ActiveDocument.Protect wdAllowOnlyFormFields, NoReset ... Please reply to the newsgroup unless you wish to avail yourself of my ...
    (microsoft.public.word.drawing.graphics)
  • Re: Question Boxes
    ... Adding Automation to your Word forms. ... Learn more VBA (macros) to automate your forms. ... > How on word 2002 do I get ASK Question boxes and A Macro> working together. ...
    (microsoft.public.word.docmanagement)