Don't save changes when user closes WB

G

Guest

I have an XL 2002 workbook and am making changes to it. I would like to be able to have the user close the workbook without be prompted to save changes. I've tried using Application.DisplayAlerts = False and haven't been able to succeed. Is there another way to do this
Should I do something in the BeforeSave event

The code follows

Thanks

Jo

Code

m_XLApp is a reference to the application

Private Sub m_XLApp_WorkbookBeforeClose(ByVal Wb As Excel.Workbook, Cancel As Boolean
Dim vFile As Varian
m_XLApp.DisplayAlerts = Fals
If Not m_fDumpOut The
If isValidWorkbook(Wb) The
vFile = m_XLApp.GetSaveAsFilename(
InitialFileName:=Wb.Worksheets(WKS_MAIN).Range(RNG_HOSPITAL_NAME).Text,
FileFilter:=FILE_FILTER,
Title:=APP_NAME

If vFile <> False The
Wb.SaveAs FileName:=vFil
Els
Cancel = Tru
End I
End I
End I
m_XLApp.DisplayAlerts = Tru
End Sub
 
N

Nick Hodge

Joe

wb.Saved=True

Should trick it into believing it is saved and not display the prompt

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)


Joe said:
I have an XL 2002 workbook and am making changes to it. I would like to
be able to have the user close the workbook without be prompted to save
changes. I've tried using Application.DisplayAlerts = False and haven't
been able to succeed. Is there another way to do this?
Should I do something in the BeforeSave event?


The code follows.

Thanks,

Joe

Code:

m_XLApp is a reference to the application.

Private Sub m_XLApp_WorkbookBeforeClose(ByVal Wb As Excel.Workbook, Cancel As Boolean)
Dim vFile As Variant
m_XLApp.DisplayAlerts = False
If Not m_fDumpOut Then
If isValidWorkbook(Wb) Then
vFile = m_XLApp.GetSaveAsFilename( _
InitialFileName:=Wb.Worksheets(WKS_MAIN).Range(RNG_HOSPITAL_NAME).Text, _
 
Top