closing a file without saving

  • Thread starter Thread starter matt dunbar
  • Start date Start date
M

matt dunbar

Hi

i wish to write a macro that stops the message

"do you want to save changes"

appearing when i close a file after using it

is there a simple way either in excel of VB Editor to
disable/prevent this message from appearing automatically?

i am needing this because i am sharing files with
colleagues in my maths dept but want them to use the files
without accidentally altering them or saving their changes
or even being asked this question when they exit the file
or excel

i have tried stuff with Before close but to no success

preventing this dialogue box from appearing when the
apllication excel is closed or when the file itself is
closed would be very useful

Regards

Matt - a techer of maths in manchester, england
 
Matt,

Just set the Cancel argument in Before_close to true.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub

and make sure that you put it in the ThisWorkbook code module.

By the way, what is a techer?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hi Bob:

Did you mean the following?:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Saved = True
End Sub

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

Regards,

Vasant.
 
I think so <vbg>.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top