View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jan Karel Pieterse Jan Karel Pieterse is offline
external usenet poster
 
Posts: 535
Default Resetting Excel commandbars on close event

Hi Alanperu,

Unfortunately this was something that I have already tried. It seems
that Excel always hangs if the reset code is part of or called from the
event handler.


Try it like this:

In a normal module:

Option Explicit

Public bClose As Boolean

Sub NowClose()
bClose = True
MsgBox "Place a call to the menuhandler here. "
ThisWorkbook.Close
End Sub

In the Thisworkbook module:

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If bClose Then Exit Sub
Cancel = True
Application.OnTime Now, "Nowclose"
End Sub


Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com