Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2008

Tip: Looking for answers? Try searching our database.

custom toolbar problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
greg - 08 Apr 2008 15:50 GMT
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
Bernie Deitrick - 08 Apr 2008 17:10 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.