Beforeclose does not work

JohnWood

New Member
Joined
Dec 2, 2014
Messages
18
Hello all,

I have the following code in a module and it does not display the message or save the workbook before closing it.What i am doing wrong?!

Thank you in advance.

Public Sub Workbook_BeforeClose()





MsgBox "Save"
ThisWorkbook.Save





End Sub
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Scott T

Well-known Member
Joined
Dec 14, 2016
Messages
2,611
Office Version
365, 2016
Platform
Windows
Did you put this in the thisworkbook module? If not move it there.
 

BigDawg15

New Member
Joined
Apr 23, 2018
Messages
27
Office Version
2016
Platform
Windows
JohnWood,

Code:
Public Sub Workbook_BeforeClose()

Thisworkbook.Save
MsgBox "Workbook Saved"

End Sub
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,099,775
Messages
5,470,711
Members
406,718
Latest member
waseem11

This Week's Hot Topics

Top