Prevent users to save workbook

  • Thread starter Thread starter Terence
  • Start date Start date
T

Terence

Hi,

How to avoid users to save the workbook? I tried to
protect workbook and protect worksheet, but doesn't work.
Can anyone help?
Thanks a lot!

Terence
 
Terence

Place this code in the "ThisWorkbook" module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
End Sub

--
XL2002
Regards

William
(e-mail address removed)

| Hi,
|
| How to avoid users to save the workbook? I tried to
| protect workbook and protect worksheet, but doesn't work.
| Can anyone help?
| Thanks a lot!
|
| Terence
 
Hi Terence

Open your workbook and elect to disable macros. Place the code in the
workbook, save and then close the file. Reopen the file (enabling macros)
and all should be as you would want.

--
XL2002
Regards

William
(e-mail address removed)

| Hi,
|
| But how can I save the code? If I add the code you
| provided, I cannot save it to the file.
| Thanks.
|
| Terence
| >-----Original Message-----
| >Terence
| >
| >Place this code in the "ThisWorkbook" module
| >
| >Private Sub Workbook_BeforeSave(ByVal SaveAsUI As
| Boolean, Cancel As
| >Boolean)
| >Cancel = True
| >End Sub
| >
| >--
| >XL2002
| >Regards
| >
| >William
| >[email protected]
| >
| >| >| Hi,
| >|
| >| How to avoid users to save the workbook? I tried to
| >| protect workbook and protect worksheet, but doesn't
| work.
| >| Can anyone help?
| >| Thanks a lot!
| >|
| >| Terence
| >
| >
| >.
| >
 
Terence,

You can save the code from the VBE, as long as the workbook has been saved
in the past. Only problem is, if the user does not enable macros, he can
still save it...

tim
 
Back
Top