Return Excel's current security setting

X

XP

Using Office 2003 and Windows XP;

Is there a way, using VBA, to return Excel's CURRENT macro security level?
I'm referring to the settings, Low, Medium, High and Very High.

Please note, I just want to get it, NOT change it. I understand that it
would only run if macros are already enabled.

Could someone please post example code?

Thanks much in advance.
 
G

Gary''s Student

From Bob Phillips:

Sub dural()
Dim oWSH As Object
Dim sResult
Set oWSH = CreateObject("WScript.Shell")
On Error Resume Next
sResult =
oWSH.RegRead("HKCU\Software\Microsoft\Office\11.0\Excel\Security\Level")
On Error GoTo 0
If Err.Number <> 0 Or sResult = "" Then
MsgBox "Read key error"
Else
MsgBox sResult
End If
Err.Clear
End Sub

The 11.0 may be to be 10.0 or 12.0
 
X

XP

Thanks GS, this is what I was looking for...

Also, do you happen to know, isn't there another method in which the
registry is not involved? Bob's method works great - but I'm thinking that
conventional VBA may traverse XL versions more seamlessly? (i.e. no checking
10.0; 11.0; 12.0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top