Disable AutoMacros in Word with PS

V

Volker Schillings

Hi,

I want to disable the AutoMacro functionality, while opening word documents
via word com object. I used following code to do this:

$services = @(Get-Service)
$msWord = new-object -ComObject "word.application" -ea silentlycontinue
$msWord.Application.DisplayAlerts = $false;
$msWordBasic = $msWord.WordBasic
$msWordBasic.GetType().InvokeMember("DisableAutoMacros",[System.Reflection.BindingFlags]::SetProperty,$null,$msWordBasic,1)
$wordDoc = $msWord.Documents.Open("somedocument.doc")
....

I am using Word 2003 and Powershell 1. When I run these lines of code, I
always get an exception. Does anybody knows how to disable the automacros
with powershell?

Best wishes!

Volker
 

My Computer

J

Justin Rich

i bet its in the registry some place..
you can use a registry monitor tool (check sysinternals) to see whats
changed while you disable them...

"Volker Schillings" <[email protected]> wrote in
message news:[email protected]

> Hi,
>
> I want to disable the AutoMacro functionality, while opening word
> documents
> via word com object. I used following code to do this:
>
> $services = @(Get-Service)
> $msWord = new-object -ComObject "word.application" -ea silentlycontinue
> $msWord.Application.DisplayAlerts = $false;
> $msWordBasic = $msWord.WordBasic
> $msWordBasic.GetType().InvokeMember("DisableAutoMacros",[System.Reflection.BindingFlags]::SetProperty,$null,$msWordBasic,1)
> $wordDoc = $msWord.Documents.Open("somedocument.doc")
> ...
>
> I am using Word 2003 and Powershell 1. When I run these lines of code, I
> always get an exception. Does anybody knows how to disable the automacros
> with powershell?
>
> Best wishes!
>
> Volker
>
 

My Computer

Top