Hi there fellow Excel users,
I'm pretty new to VBA (but studied C++ and other languages).
I've come accross a problem with a BeforeSave procedure not executing properly when fired by Me.Save as part of a BeforeClose procedure.
Consider the piece of code below.
When manually saving (through Ctrl+S), the Workbook_BeforeSave event is fired and everything works as expected.
However, firing the BeforeClose event does not bring the expected result. The "Me.Save" line in the BeforeClose effectively fires the Workbook_BeforeSave event, as confirmed by the MsgBox that pop ups, but the two ThisWorkbook.Worksheets().Visible lines are not getting executed.
I don't quite understand why it's acting like this, as the code seem pretty simple and logical to me. Is there some special restriction that I wouldn't know about event procedures that would prevent this piece of code from working properly?
Please Login or Register to view this content.
Bookmarks