> I then highlighted the name of this custom toolbar in Customize/Toolbars
and
> clicked delete,
The toolbar is deleted from Excel. If it remains deleted it will be deleted
from Excel's toolbar file when Excel closes (if it existed in the file when
Excel started).
However the toolbar remains attached to your wb, when you next open it the
toolbar will be re-created and added to Excel's Toolbars. If you don't
delete it it will reappear when you next start Excel even without loading
the file it was attached to.
To do what I think you want requires a bit of help.-
In the ThisWorkbokk module (right-click the xl icon left of the File menu
Private Sub Workbook_Activate()
DoMyBar bVis:=True, bDelete:=False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
DoMyBar bVis:=False, bDelete:=True
End Sub
Private Sub Workbook_Deactivate()
DoMyBar bVis:=False, bDelete:=False
End Sub
Private Sub DoMyBar(bVis As Boolean, bDelete As Boolean)
Dim cbar As CommandBar
On Error Resume Next
Set cbar = Application.CommandBars("TestBar") 'Change "TestBar" to suit
On Error GoTo 0
If Not cbar Is Nothing Then
cbar.Visible = bVis
If bDelete Then
cbar.Delete
End If
ElseIf bVis Then
'code to create and attach the bar
End If
End Sub
Regards,
Peter T
Personaly I don't attach toolbars but recreate and destroy when the wb opens
and closes, possibly also toggle it visible in the Activate/Deactivate
events.
Regards,
Peter T
"Woodsman" <(E-Mail Removed)> wrote in message
news:F43518A5-043C-4E64-981E-(E-Mail Removed)...
> I clicked 'Attach' for my custom toolbar while the relevant workbook was
open
> and copied it into the 'Toolbars in Workbook' window.
> I then highlighted the name of this custom toolbar in Customize/Toolbars
and
> clicked delete, to delete it from the workspace, so that it would not show
up
> in other workbooks.
> However, it also disappeared from the workbook where I need it, even
though
> in the Attach Toolbars window it is still shown in the box 'Toolbars in
> Workbook'. Upon closing (and saving) and opening the workbook, it shows up
> again but it also shows up in other Excel workbooks as well as in the
> Customize/Toolbars listing with its box checked.
> I want this toolbar to show up only in this one workbook. What am I doing
> wrong?
> Thanks.
>
|