closing a file without saving

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
 
B

Bob Phillips

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)
 
V

Vasant Nanavati

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.
 
B

Bob Phillips

I think so <vbg>.

--

HTH

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

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