Remarks
Closing a workbook from Visual Basic doesn't run any Auto_Close macros in
the workbook. Use the RunAutoMacros method to run the auto close macros.
Example
This example closes Book1.xls and discards any changes that have been made
to it.
the application asks if you want to save if there have been any changes.
WB.Close False
is the easiest way to overcome this - where wb is the workbook obkect set to
the workbook we're dealing with.
Also , we could clear the dirty flag which tells excel whether the sheets
have changed or not in the ThisWorkbook's before close event. A value of
False would trigger the application alert to save.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub
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.