Name
Application.AutomationSecurity [=MsoAutomationSecurity]
Synopsis
Set or returns the macro security setting used when opening Office documents in code. Possible settings are:
-
msoAutomationSecurityLow Enable all macros. This is the default.
-
msoAutomationSecurityByUI Use the security setting specified in the Security dialog box.
-
msoAutomationSecurityForceDisable Disable all without showing any security alerts.
These settings apply only to files opened in code. Files opened by the user apply the settings in the Security dialog box.
The default setting for this property is a security hole created to provide backward compatibility with multifile macros written for earlier versions of Excel. You should close this hole in your own code by setting the property to msoAutomationSecurityByUI before opening files, as shown here:
Sub TestMacroSecurity( )
' Enable macro security on file to open
Application.AutomationSecurity = msoAutomationSecurityByUI
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
' Get a file
.Show
' Open it.
Application.Workbooks.Open .SelectedItems(1)
End With
End SubBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access