Jump to content

Recommended Posts

Posted

I am trying to change the Microsoft Word macro security settings on Office 2002/XP. I am trying to do this using COM. I looked up some of the doc's and found a few things, but haven't been able to get this working. I am getting no errors in Scite with this. But I check word and the macro security hasn't changed. Help!?

$oWord = ObjCreate('Word.Application.10')
$oWordMacro = $oWord.AutomationSecurity
$oWordMacro = 'msoAutomationSecurityLow'

This is from Microsoft, found this to help with the COM objects. Below is the most relevant part.

http://office.microsoft.com/en-us/orkXP/HA011362661033.aspx

Programming-related security issue

Macro security prior to Office XP was not enabled that is, security was set to Low by Office applications started by an executable program making a call into the application object. Therefore, any macro would run when an application like Word opened a document and instructed it to run a macro, regardless of whether the macro was trusted or not. To address this issue of low security, a new security method was added to all VBA application objects called AutomationSecurity. This method can be used with the application object for each Office application.

Example:

Application.AutomationSecurity=msoAutomationSecurityLow

The values for use with this method are:

* msoAutomationSecurityLow

Sets the macro security to Low for this application; macros run without checking their certificate for authenticity.

* msoAutomationSecurityByUI

Sets the macro security to the same level as currently set in the user interface for the application (as found in the Security dialog).

* msoAutomationSecurityForceDisable

Sets the macro security level to High; all macros must be from a trusted source in order to run.

For programmers who need to instruct Office applications to open files and run macros, it is recommended they set this method to msoAutomationSecurityByUI prior to opening a file to conform to the security level set for the application by the user. For instances where high security is required, use the msoAutomationSecurityForceDisable to disable the running of any macros.

Posted

Tried this by following the COM/ILE reference. Tried using the same type of thing that was used for the Excel stuff, but didn't work for me.

$oWord = ObjCreate('Word.Application')
$oWord.ApplicationSecurity = 'msoAutomationSecurityLow'

Getting a "The requested action with this object has failed.:" message

  • Moderators
Posted

You may want to take a look at my Word Automation Library (see my signature), I think you will find it very easy to use.

This example should work along with my library mentioned above.

#include <Word.au3>

Const $msoAutomationSecurityByUI = 2
Const $msoAutomationSecurityForceDisable = 3
Const $msoAutomationSecurityLow = 1

$oWordApp = _WordCreate()
$oWordApp.AutomationSecurity = $msoAutomationSecurityLow
Posted

I used the code you supplied. I get no errors. It opens up a word document. I tried closing then re-opening, and if I go to "Tools>Macro>Security" it is still set to high.

Posted

This is what is in the console after running.

>Running:(3.2.2.0):C:\Program Files\AutoIt3\autoit3.exe "H:\AutoIt\Example Scripts\Using COM\Word COM test.au3"

1

1

+>AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 2.743

Posted

Anything anyone? I tried looking up MSDN stuff, but couldn't find anything. I'm not sure why this isn't working. This sets the option permanently? Not just for the current document right?

Posted

Can someone please help me with this. This is the last piece that isn't working that I need. I still have been unable to get it working.

  • Moderators
Posted

Sorry for the late reply, I haven't been around much the last few days.

First of all what environment are you testing this with?

When I get a chance I'll dig into it and see what I can figure out.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...