View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Hannah Lu[_2_] Hannah Lu[_2_] is offline
external usenet poster
 
Posts: 6
Default Determining if the user enabled macros

Hi Samuel,
I usually will create a "Welcome Message" sheet that says something like
"Please enable macros to continue," usually with brief instructions in case
they don't know how. That way when they open the workbook if they see the
Welcome Message sheet they don't have macros enabled and need to enable them
to make the other sheets visible.
Then the code looks like this:

Private Sub Workbook_Open()
'Hides the Welcome Message Sheet and displays other sheets
Worksheets("Sheet1").Visible = True
Worksheets("Sheet2").Visible = True
Worksheets("Welcome Message").Visible = xlVeryHidden
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Worksheets("Welcome Message").Visible = True
Worksheets("Sheet1").Visible = xlVeryHidden
Worksheets("Sheet2").Visible = xlVeryHidden
End Sub

You want to be sure that you order the show/hide procedures as shown above,
you'll get an error if, in the BeforeClose event, you hide Sheet1 and Sheet2
before showing Welcome Message.
Good luck!
-Hannah





"Samuel Looney" wrote:

How can it be determined whether or not a user enabled macros? The workbook I
created has a lot of code that validates data input and I do not want anyone
to change the information unless the macros are enabled. Any ideas?