View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Klaus Klaus is offline
external usenet poster
 
Posts: 11
Default Checking for security level to allow macros to run

I can see this working for "Trusted Sources", but that is not my case. All I
can do is try to check for the Security Level. Any ideas?
Klaus

"Don Wiss" wrote:

On Mon, 11 Jul 2005, Klaus wrote:

Is there any way to check programmatically, if the security level is set to
allow macros to run, and then 1) display a message indicating that the
security level must be set to medium and/or the macros must be enabled; and
2) stop any activity on the workbook and force the user to restart excel with
macros enabled?


This is what I use (unwrap wrapping in MsgBox):

Function DoesProjectExist(AddInName As String) As Boolean
' addin name is case sensitive. is project name, not file name
Dim W As Object
DoesProjectExist = False
On Error GoTo ErrSection
For Each W In Application.VBE.VBProjects
If W.Name = AddInName Then DoesProjectExist = True
Next
Exit Function

ErrSection:
MsgBox "In order for this to work properly you need to change a
setting. Go to Tools - Macros - Security... - Trusted Sources tab. Then
both boxes at the bottom have to be checked.", vbCritical, "Macros Are Not
Trusted Source"

End Function