Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a macro which needs System Access
As it would be difficult to force enduser's local security, I would prefer to place a warning if his Current Local Security is set to "Don't Run at All" or "Only Safe Mode". How do I do that? Is there a system function that I can use? Or do I need to write a new macro for checking this setting?
As far as I know there is only macro function for that.
I have used following setup (in desktop mode, maybe works in IE also):
- create variable vModuleSecurityMode
- create warning message text box with show condition vModuleSecurityMode<2
- add following actions to Document Properties OnOpen trigger:
1) set variable vModuleSecurityMode to 0
2) run macro "securitycheck"
sub securitycheck
set v = ActiveDocument.Variables("vModuleSecurityMode")
' OnOpen trigger sets this variable to 0
' then runs this macro to check security level and change the variable
' if System Access is allowed then 2, if safe mode then 1
' Blocked mode blocks the macro and variable stay 0
' Front page has warning message displayed when vModuleSecurityMode < 2
ms = ActiveDocument.GetCurrentModuleSecurity '2=System Access, 1=SafeMode
v.SetContent ms,false
end sub
So, the warning message will show up when macros are blocked or limited to safe mode.
It's useful to hint the Ctrl+Shift+M in the same message so user can fix it immediately.
Hi Tanel,
Very helpful answer. However, I still have one behavior that I can't manage. Here is my current implementation:
At the opening of the document:
- vModuleSecurityMode is set to 0
- macro securitycheck is executed.
Problem is that macro won't get executed for user who has the security level = 0 (Stop all module Script).
So, I made an alternative to your answer, I am not using a textbox for showing the message, but an alert (with the same condition as you mentioned, and with following settings:
- Show a pop-up / Mode = Interactive
- Events: On Open
Advantage: Even people with security level = 0 will get the pop-up at the opening of the document
Problem: Alert will run before the macro (that I set at the opening of the document) so vModuleSecurityMode is still set to 0 before the alert is fired. and even people who has security level = 1 or 2, will get the pop-up ;(.
I am trying to find alternative, but so far, nothing.
I don't see a good way to make it work with alerts.
But a big red warning in a text box is almost as good. It also shows up when macros are blocked. You can even hide critical worksheets while vModuleSecurityMode < 2
Create a special Worksheet with the Information "Security Level to low" and the Ctrl+Shift+M Information.
Insert a Button "Recheck Module Security" to fire a macro to recheck Module Security.
Show this worksheet only, when Variable = 0 or 1.
All other Sheets should be visible only when Variable = 2.
On Start fire a macro to find out, which ModuleSecurity is available (ActiveDocument.GetCurrentModuleSecurity).
Set the Variable to 1 or 2. If Security Level is to low to fire the macro, the Variable is still 0.
Regards, Martin