close without saving
When can accomplish this with two event macros and a tiny trick.
Put these in the workbook code area:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.Saved = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ActiveWorkbook.Saved = True
Cancel = True
End Sub
These should prevent attempts to save.
HOWEVER: the tiny trick - Once you have installed the macros, even YOU
won't be able to save the result and so the macros will be "lost". So:
1. Install the macros
2. set Application.EnableEvents to False
3. save the file
Once the file has been re-opened, EnableEvents will be True and subsequent
attempts to save will fail!
--
Gary''s Student - gsnu200829
"calebjill" wrote:
I have a workbook that when opened by a certain user which I have tied to a
form I want it to be editable but when open by other users I want it to be in
read only format and no prompt or ability to save the document. I am
currently using a macro to select all sheets, lock all cells, then protect
all sheets which prevents editing, however I do not want them to be able to
save it. This macro for prevention only runs when certain users open the
workbook.
any help would be appreciated.
|