I have created a custom toolbar. And attached it to the document.
Through customize>attach>attach toolbars
And wrote vba code. and assigned buttons to the code.
However when I send the document to someone else,
they see the custom toolbar. but there are no buttons on it.
I am thinking this is something easy. which I just don't see.
anyone know this problem?
thanks
Greg,
My customary advice it to create and destroy the commandbar through code using the workbook's open
and close events. See below.
HTH,
Bernie
MS Excel MVP
In the workbook's Thisworkbook object code module, place the following code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
DeleteCommandbar
End Sub
Private Sub Workbook_Open()
CreateCommandbar
End Sub
In a regular code module, place the following:
Dim myBar As CommandBar
Dim myButton As CommandBarButton
Sub CreateCommandbar()
On Error Resume Next
DeleteCommandBar
Set myBar = Application.CommandBars.Add("My Bar")
With myBar
.Position = msoBarTop
.Visible = True
.Enabled = True
Set myButton = .Controls.Add(Type:=msoControlButton, ID:=23)
With myButton
.Caption = "Hello"
.Style = msoButtonIcon
.FaceId = 137
.Enabled = True
.OnAction = "SayHello"
End With
End With
End Sub
Sub DeleteCommandBar()
'Delete the commandbar if it already exists
On Error Resume Next
Application.CommandBars("My Bar").Delete
End Sub
Sub SayHello()
MsgBox "Hello there"
End Sub
You can add as many buttons or other menu items as you like.
>I have created a custom toolbar. And attached it to the document.
> Through customize>attach>attach toolbars
[quoted text clipped - 4 lines]
> anyone know this problem?
> thanks