Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

Introduction

The Application.AutomationSecurity property allows the Microsoft Office programs that are listed in the "Applies to" 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


More information

AutomationSecurity property

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:

PropertyDescription
msoAutomationSecurityForceDisableDisables the macros in all documents that are opened by previously enabled macros. This setting provides the highest level of security.
msoAutomationSecurityByUIRespects the Warn before opening a file that contains macros preference for macros in all documents opened by previously enabled macros.
msoAutomationSecurityLowEnables the macros in all document that are opened by previously enabled macros.


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.

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:

PropertyDescription
msoAutomationSecurityForceDisableDisables the macros in all documents that were opened by previously enabled macros. This setting provides the highest level of security.
msoAutomationSecurityByUIRespects the Enable macro virus protection preference for macros in all documents that were opened by previously enabled macros.
msoAutomationSecurityLowEnables the macros in all the document that were opened by previously enabled macros.


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.

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:

PropertyDescription
msoAutomationSecurityForceDisableDisables the macros in all the documents that were opened by previously enabled macros. This setting provides the highest level of security.
msoAutomationSecurityByUIRespects the Warn before opening a file that contains macros preference for macros in all the documents that were opened by previously enabled macros.
msoAutomationSecurityLowEnables the macros in all the document that were opened by previously enabled macros.


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.

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

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


Keywords: KB886633, kbhowto, dftsdahomeportal

↑ Back to the top

Article Info
Article ID : 886633
Revision : 6
Created on : 9/12/2011
Published on : 9/12/2011
Exists online : False
Views : 1113