Toolbar Question

D

DJ

Hi everyone,

I would appreciate very much some help with probably a simple problem.
Let's say I have a toolbar that has two tools that execute two VBA macros.
I want this toolbar to be a part of this workbook whenver I open it. But
when I save the workbook and open it on another machine, the toolbar is not
there. I don't understand how to make the toolbar persistent whenever I
open this workbook. I'm sure it is a simple issue but I cannot seem to find
a solution. Thanks in advance for the assistance.

Dave
 
G

Gord Dibben

DJ

Tools>Customize>Toolbars>Attach.

Select the two-button Toolbar and hit "copy" to the right-side.

Save the workbook.

Gord Dibben Excel MVP
 
D

Dave Peterson

If you're interested, here's a shell that I keep when I want to add a custom
menubar:

In a general module:

Option Explicit
Sub create_menubar()

Dim i As Long

Dim mac_names As Variant
Dim cap_names As Variant
Dim tip_text As Variant

Call remove_menubar

mac_names = Array("mac1", _
"mac2", _
"mac3")

cap_names = Array("caption 1", _
"caption 2", _
"caption 3")

tip_text = Array("tip 1", _
"tip 2", _
"tip 3")

With Application.CommandBars.Add
.Name = "Test99"
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating

For i = LBound(mac_names) To UBound(mac_names)
With .Controls.Add(Type:=msoControlButton)
.OnAction = ThisWorkbook.Name & "!" & mac_names(i)
.Caption = cap_names(i)
.Style = msoButtonIconAndCaption
.FaceId = 71 + i
.TooltipText = tip_text(i)
End With
Next i
End With
End Sub

Sub remove_menubar()
On Error Resume Next
Application.CommandBars("Test99").Delete
On Error GoTo 0
End Sub


Under Thisworkbook:

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call remove_menubar
End Sub

Private Sub Workbook_Open()
Call create_menubar
End Sub

====
The Mac_names, cap_names, and tip_text are set up for 3 elements. But just
delete/add from each of these and the code will loop through them (even if
there's just one) to add buttons to a temporary toolbar.

(make sure you have the same number of elements for each array.)

<<snipped>>
 
Top