Problem with Workbook_BeforeClose event

T

tempest0123

Hi all.

I am having trouble figuring out a strange behavior with the
Workbook_BeforeClose event procedure.

Suppose I have a Workbook_BeforeClose event procedure that makes some
changes to some worksheets and then save the workbook before closing.
The changes made by the event procedure would be saved only if the
workbook is closed manually in Excel by a user.

However, if the workbook is opened and then closed by an external VB
program using Excel application object, changes made by the
Workbook_BeforeClose event procedure are NOT saved. In fact, the
modification date/time of the Workbook file remains unchanged.

To make sure the Workbook_BeforeClose ran if the workbook was closed
by the external program, I placed several MsgBox statements in the
Workbook_BeforeClose event procedure. And sure enough all the MsgBox
messages were displayed, but changes were not saved.

Does anyone know what is going on here with the Workbook_BeforeClose
event?

Thanks.
Jason
 
G

Guest

It sounds like the changes are being made in the _BeforeClose procedure but
the workbook is not being saved. In your app are you doing

MyWorkbook.Save

before

MyWorkbook.Close

....just a hunch
 

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