Exit File...

G

Guest

Hi...

Is there code that will shutdown an excel file if when prompted the user
selects diable macros when entering the file. I want to protect my work from
excel pirates! Therefore, when enable macros is selected the file will load
as intended?

Any help will be greatly appreciated...

Gordon...
 
R

Ron de Bruin

Hi Gordon

If the user disable macros no code will run.

A good way is to hide all sheets except one and unhide them in
the workbook open event.
Place a message on that sheet with "you must enabled macro's to work with this file"
And hide the sheets in the beforeclose event.
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
You must also protect your project in the VBA editor because a user can unhide
the sheets there also if you don't do that

Some example code to do this
the first Sheet stay always visible

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top