_Application.AutomationSecurity Property
Returns or sets an MsoAutomationSecurity constant that represents the security mode Microsoft Excel uses when programmatically opening files.
Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)
Syntax
'Declaration
Property AutomationSecurity As MsoAutomationSecurity
Get
Set
'Usage
Dim instance As _Application
Dim value As MsoAutomationSecurity
value = instance.AutomationSecurity
instance.AutomationSecurity = value
MsoAutomationSecurity AutomationSecurity { get; set; }
Property Value
Type: Microsoft.Office.Core.MsoAutomationSecurity
Remarks
This property is automatically set to msoAutomationSecurityLow when the application is started. Therefore, to avoid breaking solutions that rely on the default setting, you should be careful to reset this property to msoAutomationSecurityLow after programmatically opening a file. Also, this property should be set immediately before and after opening a file programmatically to avoid malicious subversion.
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.
Note
This setting does not disable Microsoft Excel 4.0 macros. If a file that contains Microsoft Excel 4.0 macros is opened programmatically, the user will be prompted to decide whether or not to open the file.
msoAutomationSecurityLow Enables all macros. This is the default value when the application is started.
Setting ScreenUpdating to False does not affect alerts and will not affect security warnings. The DisplayAlerts setting will not apply to security warnings. For example, if the user sets DisplayAlerts equal to False and AutomationSecurity 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.