#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default close without saving

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File/Close automatically saving changes without prompt Joe@SAA Excel Discussion (Misc queries) 0 June 23rd 08 10:31 PM
close w/o saving jatman Excel Worksheet Functions 5 February 29th 08 02:52 PM
Macro to Prompt User to Close After Saving Rutabaga Excel Discussion (Misc queries) 2 July 12th 07 12:38 AM
VBA - Close without saving changes PaulW Excel Discussion (Misc queries) 2 July 27th 06 01:22 PM
Am i the first person to close and excel file, without saving chan Cjbrad Excel Discussion (Misc queries) 3 March 2nd 06 07:58 PM


All times are GMT +1. The time now is 08:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"