This code allowed me to supress the security warning message
in Excel 2003. I have no other adivce to offer if you can't make
it work in your Excel version.
With my security level set to the 'Very High' level, I was able to open
from a separate workbook (#1 workbook with the code below) a workbook (#2) that contains
a macro, plus run the macro (in #2) without the warning. When opening the #2 workbook
in a separate session, I could not run the macro due to the security level, as expected.
What I can't explain is why the #1 workbook lets me run a macro to
change the security level when the security level is at Very High. I assigned
the keys Ctrl+e to run that macro (in #1).
edit: Later testing required that I open the #1 workbook with a security level of medium or low.
Thanks to Microsoft's MDSN website for an example of how to use
Application.AutomationSecurity.
Good luck.
Sub OpenWB_LowSecurity()
Dim secAutomation As MsoAutomationSecurity
Dim wb As Workbook
Dim FName As String
secAutomation = Application.AutomationSecurity
Application.AutomationSecurity = msoAutomationSecurityLow
On Error Resume Next
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
On Error GoTo 0
'If FName Then Set wb = Workbooks.Open(FName) boolean test in error here, I think. next line of code should work.
If (Dir(FName) <> "") Then Set wb = Workbooks.Open(FName)
Application.AutomationSecurity = secAutomation
End Sub
Bookmarks