Microsoft KB Archive/886633

= How to use the Application.AutomationSecurity property in Office v.X and in Office 2004 for Mac =

Article ID: 886633

Article Last Modified on 7/1/2005

-

APPLIES TO


 * Microsoft Office 2004 for Mac Standard Edition
 * Microsoft Excel 2004 for Mac
 * Microsoft PowerPoint 2004 for Mac
 * Microsoft Word 2004 for Mac
 * Microsoft Office X for Mac Standard Edition
 * Microsoft Excel X for Mac
 * Microsoft PowerPoint X for Mac
 * Microsoft Word X for Mac
 * Microsoft Encarta Encyclopedia 2000 Concise Edition
 * Microsoft Encarta Encyclopedia 2000 Deluxe Edition

-





For a Microsoft Office XP version of this article, see 317405.



Article Contents

 * INTRODUCTION
 * AutomationSecurity property
 * Microsoft Word
 * Microsoft PowerPoint
 * Microsoft Excel
 * Sample code
 * Implications



INTRODUCTION
The Application.AutomationSecurity property allows the Microsoft Office programs that are listed in the &quot;Applies to&quot; section to support security for solutions that programmatically open a document but are not sure whether the macros in a document are safe. A developer may want to control whether the Office solution displays the security warnings to the user for these documents.

This article describes how a developer can use the Application.AutomationSecurity property to control the security warning that appears in Microsoft Office for Mac programs.

Note You may have to update your Microsoft Office for Mac program to use the Application.AutomationSecurity property.

Microsoft Office 2004 for Mac

To use the Application.AutomationSecurity property on a computer that has a Microsoft Office 2004 for Mac program installed, install Microsoft Office 2004 for Mac Service Pack 1 (11.1.0).

For additional information about how to obtain the Microsoft Office 2004 for Mac Service Pack 1 (11.1.0), click the following article number to view the article in the Microsoft Knowledge Base:

883951 Description of the Microsoft Office 2004 for Mac service pack 1 (11.1.0)

Microsoft Office X for Mac

To use the Application.AutomationSecurity property on a computer that has a Microsoft Office X for Mac program installed, install Microsoft Office v. X for Mac Security Update (10.1.6).

For additional information about how to obtain the Microsoft Office v.X for Mac Security Update (10.1.6), click the following article number to view the article in the Microsoft Knowledge Base:

883952 Description of the Microsoft Office v.X for Mac Security Update (10.1.6)

back to the top



Microsoft Word
Microsoft Word now supports an additional level of security that affects macros that open other Office documents that contain macros.

The setting must be enabled as part of the Microsoft Visual Basic for Applications (VBA) macro code. You can use the Application.AutomationSecurity property to set the level of security as listed in the following table:

The Application.AutomationSecurity property interacts with the Warn before opening a file that contains macros preference in the following ways:
 * If the Application.AutomationSecurity property is set to msoAutomationSecurityLow, the user is not prompted to enable macros for documents that were opened by a macro regardless of the setting of the macro warning option. Macros in these documents are automatically enabled.
 * If the Application.AutomationSecurity property is set to msoAutomationSecurityForceDisable, the user is not prompted to enable macros for documents that were opened by a macro regardless of the setting of the macro warning option. Macros in these documents are automatically disabled.

back to the top

Microsoft PowerPoint
Security in Microsoft PowerPoint has been improved when you open a document that contains macros. Additionally, PowerPoint supports an additional level of security that affects macros that open other Office documents that contain macros.

The setting must be enabled as part of the VBA macro code. You can use the Application.AutomationSecurity property to set the level of security as listed in the following table:

The Application.AutomationSecurity property interacts with the Enable macro virus protection preference in the following ways:
 * If the Application.AutomationSecurity property is set to msoAutomationSecurityLow, the user is not prompted to enable macros for documents that were opened by a macro regardless of the setting of the macro warning option. Macros in these documents are automatically enabled.
 * If the Application.AutomationSecurity property is set to msoAutomationSecurityForceDisable, the user is not prompted to enable macros for documents that were opened by a macro regardless of the setting of the macro warning option. Macros in these documents are automatically disabled.

back to the top

Microsoft Excel
Microsoft Excel now supports an additional level of security that affects macros that open other Office documents that contain macros.

The setting must be enabled as part of the VBA macro code. You can use the Application.AutomationSecurity property to set the level of security as listed in the following table:

The Application.AutomationSecurity property interacts with the Warn before opening a file that contains macros preference in the following ways:
 * If the Application.AutomationSecurity property is set to msoAutomationSecurityLow, the user is not prompted to enable macros for documents that were opened by a macro regardless of the setting of the macro warning option. Macros in these documents are automatically enabled.
 * If the Application.AutomationSecurity property is set to msoAutomationSecurityForceDisable, the user is not prompted to enable macros for documents that were opened by a macro regardless of the setting of the macro warning option. Macros in these documents are automatically disabled.

back to the top

Sample code
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Sub Security Dim secAutomation As MsoAutomationSecurity

secAutomation = Application.AutomationSecurity Application.AutomationSecurity = msoAutomationSecurityForceDisable

With Application.FileDialog(msoFileDialogOpen) .Show .Execute End With

Application.AutomationSecurity = secAutomation End Sub back to the top

Implications
If the Application.AutomationSecurity property is set to msoAutomationSecurityByUI and the Warn before opening a file that contains macros preference is selected, you receive a warning dialog box whenever a macro tries to open a file that contains a macro. If you click Do Not Open to deny this attempt, you receive the following error message.

Run-time error '4198'

Command failed

Additionally, if a macro tries to open a file that contains a macro, the attempt will fail if both of the following conditions are true:
 * The Application.AutomationSecurity property option is set to msoAutomationSecurityForceDisable.
 * The attempt to open the file is made through an Office API macro. This includes macros that are written in VBA, XLM in Excel, and WordBasic in Word.

back to the top

Additional query words: officex offx office2004 off2004 offmac macintosh security alerts

Keywords: kbhowto KB886633

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.