Don't let user close. Use macro button to close?

M

mike

How can I force this? Can I?

I need to make sure the workbook is saved before it's closed, make sure
it's not closed without being saved. I have a "Close" button that goes
to a macro that saves.

I thought of putting a save macro in as workbook.deactivate code, but
then my button would be redundant.

Should I just lose the button and stick with workbook.deactivate?
 
G

Guest

How about in the before close event add in the save. Add this code to the
ThisWorkbook module (right click the XL icon next to the word file in Excel
and select View Code)

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not ThisWorkbook.Saved Then ThisWorkbook.Save
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.

Ask a Question

Top