Aaron -
I owe you an apology.
I had written the class module using the App_WorkbookDeactivate() event,
but in this thread, I wrote that I was using the App_WorkbookClose()
event.
Using the Workbook_Close() or the App_WorkbookClose() events will, of
course, exhibit exactly the behavior you describe.
The App_WorkbookDeactivate event is the last event fired when closing a
workbook - it happens after the file is saved, if in fact it is saved.
If the user cancels the save, the event isn't fired at all, so the
control is never dimmed.
When I tested it, I naturally didn't see the control dimmed if I
cancelled the save, so I couldn't understand why you were seeing what
you did. Obviously I locked onto the wrong piece of information.
In any case, here's the correct code in my DimButtonClass module:
Public WithEvents DBApp As Application
Private Sub DBApp_WorkbookDeactivate(ByVal Wb As Excel.Workbook)
On Error Resume Next
CommandBars.FindControl(Tag:=csCTRLTAG).Enabled = _
(Workbooks.Count > 1)
On Error GoTo 0
End Sub
Private Sub DBApp_WorkbookOpen(ByVal Wb As Excel.Workbook)
On Error Resume Next
CommandBars.FindControl(Tag:=csCTRLTAG).Enabled = True
On Error GoTo 0
End Sub
Again, sorry for my mix-up.