AutomationSecurity Property

MsoAutomationSecurity

MsoAutomationSecurity can be one of these MsoAutomationSecurity constants.
msoAutomationSecurityByUI Uses the security setting specified in the Security dialog box.
msoAutomationSecurityForceDisable Disables all macros in all files opened programmatically without showing any security alerts.
msoAutomationSecurityLow Enables all macros. This is the default value when the application is started.

expression.AutomationSecurity

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Remarks

The value of the DisplayAlerts property will not apply to security warnings. For example, if the user sets the DisplayAlerts property equal to False and the AutomationSecurity property to msoAutomationSecurityByUI, while the user is on Medium security level, then there will be security warnings while the macro is running. This allows the macro to trap file open errors, while still showing the security warning if the file open succeeds.

Example

This example captures the current automation security setting, changes the setting to disable macros, displays the Open dialog box, and after opening the selected presentation, sets the automation security back to its original setting.

Sub Security()
    Dim secAutomation As MsoAutomationSecurity

    secAutomation = Application.AutomationSecurity

    Application.AutomationSecurity = msoAutomationSecurityForceDisable
    Application.FileDialog(msoFileDialogOpen).Show

    Application.AutomationSecurity = secAutomation

End Sub

Applies to | Application Object