D
daithimcc
(Excel X for Mac OSX)
Can anyone tell me what I should be doing to delete a custom toolbar
when a particular workbook closes?
In the workbook module I have:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = False
itsclsing = Not Cancel
End Sub
Private Sub Workbook_Deactivate()
If itsclsing Then
ThisWorkbook.Application.CommandBars("ctoolbar").Delete
End Sub
(I'm not clear exactly how Cancel is working above-perhaps this would
make a solution more obvious. I tried to use itsclsing to record
whether cancel had been pressed).
The above works fine when this is the only workbook open. (If Cancel is
pressed the toolbar remains, it disappears otherwise).
However if I have another workbook open and activated and I quit the
application, I get the usual prompts and e.g. if I choose not to save,
the toolbar is not deleted (it appears the next time I open Excel,
without opening the workbook it's attached to).
I would be grateful for any advice.
Can anyone tell me what I should be doing to delete a custom toolbar
when a particular workbook closes?
In the workbook module I have:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = False
itsclsing = Not Cancel
End Sub
Private Sub Workbook_Deactivate()
If itsclsing Then
ThisWorkbook.Application.CommandBars("ctoolbar").Delete
End Sub
(I'm not clear exactly how Cancel is working above-perhaps this would
make a solution more obvious. I tried to use itsclsing to record
whether cancel had been pressed).
The above works fine when this is the only workbook open. (If Cancel is
pressed the toolbar remains, it disappears otherwise).
However if I have another workbook open and activated and I quit the
application, I get the usual prompts and e.g. if I choose not to save,
the toolbar is not deleted (it appears the next time I open Excel,
without opening the workbook it's attached to).
I would be grateful for any advice.