Click on "Close" and it saves & closes. How to do it?

  • Thread starter Thread starter Marvin Hlavac
  • Start date Start date
M

Marvin Hlavac

I'd like to be able to just click on Close and the workbook would be saved
and closed without the "Dou You Want to Save, Yes or No" dialog.

Thanks in advance.
 
Put the following into the ThisWorkbook module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Name <> FullName Then
Save
Close
End If
End Sub

Note that if you have any BeforeSave or BeforeClose code, it may interfere
with this macro unless appropriately handled.
 
Thanks Vasant,

As always the code you supplied works exactly as intended. I only hope that
one day I will know at least 5% of what you do :-)

--
Regards,
Marvin Hlavac
Toronto, Canada
 
Just stick around the newsgroups and before you know it, you'll be an
expert! That's how many of us learned most of what we know.
 
Back
Top