ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Return Excel's current security setting (https://www.excelbanter.com/excel-programming/393594-return-excels-current-security-setting.html)

XP

Return Excel's current security setting
 
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.

Gary''s Student

Return Excel's current security setting
 
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
--
Gary''s Student - gsnu200734


"XP" wrote:

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.


XP

Return Excel's current security setting
 
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)

"Gary''s Student" wrote:

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
--
Gary''s Student - gsnu200734


"XP" wrote:

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.



All times are GMT +1. The time now is 04:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com