Opening Excel W/ Macros.

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Hi,

Is there a way to only allow an excel file to be opened
if they choose to enable macros?

In other words if they try and open the file and
choose 'disable' macros then the file will not open and
give them an error message telling them they must
choose 'enable' macros to open this file.

Thanks

Ben
 
Hi Ben

One way

A good way is to hide all sheets except one and run the macro ShowAll in
the workbook open event.
Place a message on that sheet(first one) with "you must enabled macro's to work with this file"
So the user can't use the workbook if he disable macro's.
If he do the workbook open event don't run so there are no sheets
to work with
run the sub HidealmostAll to hide the sheets in the beforeclose event.

You must protect your project also in the VBA editor because a user can't unhide
the sheets there also if you don't do that


Sub HidealmostAll()
Dim a As Integer
For a = 2 To Sheets.Count
Sheets(a).Visible = xlVeryHidden
Next a
End Sub

Sub ShowAll()
Dim a As Integer
For a = 2 To Sheets.Count
Sheets(a).Visible = True
Next a
End Sub
 
-----Original Message-----
Hi Ben

One way

A good way is to hide all sheets except one and run the macro ShowAll in
the workbook open event.
Place a message on that sheet(first one) with "you must
enabled macro's to work with this file"
So the user can't use the workbook if he disable macro's.
If he do the workbook open event don't run so there are no sheets
to work with
run the sub HidealmostAll to hide the sheets in the beforeclose event.

You must protect your project also in the VBA editor because a user can't unhide
the sheets there also if you don't do that


Sub HidealmostAll()
Dim a As Integer
For a = 2 To Sheets.Count
Sheets(a).Visible = xlVeryHidden
Next a
End Sub

Sub ShowAll()
Dim a As Integer
For a = 2 To Sheets.Count
Sheets(a).Visible = True
Next a
End Sub



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




"Ben" <[email protected]> wrote in
message news:[email protected]...
 
Back
Top