Q:

Check Excel Macro Security Settings

I have a vb.net Application that starts a Excel macro.
Is there a way to check the macro Security Settings of the Excel first?
Imports Excel = Microsoft.Office.Interop.Excel
Private Sub macrotest ()

     objExcel.Workbooks.Open(strPath)

     if ***'Check her what macro Security Settings is selected!*** Then
         objExcel.Run("SortIO")
     end if
End Sub

A:

This seems to have cross-posted to the Excel VBA questions page: would you mind speaking a little more slowly?
... reads slowly ...
Well, I can give you an answer in VBA: the Excel.Application.AutomationSecurity property.
The available values are enumerated by Office.MsoAutomationSecurity:
 1  msoAutomationSecurityLow 
 2  msoAutomationSecurityByUI 
 3  msoAutomationSecurityForceDisable
These are the settings for macros available in the API exposed to VBA. The user interface, visible in the 'Developer' tab of the ribbon, corresponds to the registry settings explained by NoAlias in the previous answer:
HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Excel\Security\VBAWarnings
With the following enumerated values:

Enable all macros 
Disable all macros with notification
Disable all macros except digitally signed macros
Disable all macros without notification

If you go down the registry route, a VBA coder's advice would be to use the safe registry classes exposed by WMI scripting... And check that your user does actually have the privileges to make that registry write: there may be a registry policy in place preventing it.    

