Enable macros.....

  • Thread starter Thread starter Excel
  • Start date Start date
E

Excel

I want a message to appear on my spreadsheet (that gives directions)
if they open my file (containing a macro) and Excel does not have
macros enabled.

If Excel does have macros enabled I dont want to display anything.


I thought something like this:

"If your are seeing this message it is because your macros are
disabled. To enable macros go to.....etc"

Any ideas on how to determine this?

Thanks.
 
Since you can't use a macro to determine whether macros are enabled,
one way is to

1) Create one sheet with your message (named, say, "Warning").

2) In your ThisWorkbook code module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim wkSht As Worksheet
For Each wkSht In Worksheets
With wkSht
If .Name <> "Warning" Then
.Visible = xlVeryHidden
Else
.Visible = True
End If
End With
Next wkSht
End Sub

3) Also in your ThisWorkbook code module:

Private Sub Workbook_Open()
dim wkSht As Worksheet
For Each wkSht In Worksheets
With wkSht
.Visible = (.Name <> "Warning")
End With
Next wkSht
End Sub

Now when the workbook is closed, the working sheets will be
xlVeryHidden.

Note that this won't stop someone who wants to get in without macros
and has even a little knowledge of XL, but it serves as a useful
warning.
 
Back
Top