ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   closing a file without saving (https://www.excelbanter.com/excel-programming/283539-closing-file-without-saving.html)

Matt Dunbar

closing a file without saving
 
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



Bob Phillips[_6_]

closing a file without saving
 
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)

"matt dunbar" wrote in message
...
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





Vasant Nanavati

closing a file without saving
 
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.

"Bob Phillips" wrote in message
...
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)

"matt dunbar" wrote in message
...
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







Bob Phillips[_6_]

closing a file without saving
 
I think so <vbg.

--

HTH

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

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
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.

"Bob Phillips" wrote in message
...
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)

"matt dunbar" wrote in message
...
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










All times are GMT +1. The time now is 07:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com