By default, in Office 2003 the
AutomationSecurity property is set to low. In Microsoft Office XP, you can run a
macro to open a workbook even though the
AutomationSecurity property is set to the ForceDisable value, or if the macro
security is set to medium. However, if you use the ForceDisable value in Excel
2003, XLM macros are disabled.
If you configure the
AutomationSecurity property to the ByUI value in Excel 2003, and the macro security
is set to medium, you will receive a message that prompts you to enable or to
disable macros in the workbook. If you configure the
AutomationSecurity property to the ByUI value, and macro security is set to high,
VBA and XLM labels are automatically disabled. However, workbooks that contain
XLM ply macros will not open.
Note The
AutomationSecurity property overrides the security that is set in the user
interface. To determine the macro security in the user interface (UI), on the
Tools menu, point to
Macro, and then click
Security.
The following table provides an overview of
the behavior of the
AutomationSecurity property in Excel 2003:
Collapse this tableExpand this table
Macro Type | AutomationSecurity setting | Action |
XLM | Low | Opens workbook file and runs macros
|
VBA | Low | Opens workbook file and runs macros
|
LBL | Low | Opens workbook file and runs macros
|
XLM | ByUI | Respects macro setting in UI |
VBA | ByUI | Respects macro setting in UI |
LBL | ByUI | Respects macro setting in UI |
XLM | ForceDisable | Does not open workbook
file |
VBA | ForceDisable | Opens workbook file but
disables macros |
LBL | ForceDisable | Opens workbook file but
disables macros |
In this table, "LBL" is an Excel 4 XLM macro that is stored in
a defined name.
The AutomationSecurity property
The Application object of Microsoft Word, Microsoft Excel, and
Microsoft PowerPoint supports this property.
The
AutomationSecurity property returns or sets an MsoAutomationSecurity value that
represents the security mode that an Office 2003 program uses when it
programmatically opens files. This property is automatically set to a value of
MsoAutomationSecurityLow when the program starts. Therefore, to avoid breaking
solutions that rely on the default setting, reset this property to the
MsoAutomationSecurityLow value after you open a file programmatically. Also,
make sure that you set this property immediately before and after you open a
file programmatically to avoid malicious subversion.
The
AutomationSecurity property also permits macros to choose to open a document and to
trigger the appropriate security warning. This action is the same as if an end
user is manually opening the document. This new property does not affect the
behavior when the end user uses the user interface (UI) to open files. In this
scenario, this property does not change the settings in the
Security dialog box (on the
Tools menu, point
to
Macro, and then click
Security).
You can choose from the following
MsoAutomationSecurity values:
- MsoAutomationSecurityLow
- MsoAutomationSecurityForceDisable
- MsoAutomationSecurityByUI
The MsoAutomationSecurityLow value turns on all macros and is
the default value when you start the program. The
MsoAutomationSecurityForceDisable value disables all macros in all files that
are opened programmatically, and no security warnings appear. The
MsoAutomationSecurityByUI value uses the security setting that is controlled in
the
Security dialog box.
The value of the
DisplayAlerts property does not apply to security warnings. For example, if the
following conditions are true, security warnings appear while the macro is
running:
- You configure the DisplayAlerts property equal to false and the AutomationSecurity property to the MsoAutomationSecurityByUI value.
- The user's security is set to medium.
This action permits the macro to trap "file open" errors, while
still displaying the security warning if the "file open" succeeds.
You
can use the following values for the
DisplayAlerts property:
- 3 = MsoAutomationSecurityForceDisable
- 2 = MsoAutomationSecurityByUI
- 1 = MsoAutomationSecurityLow