troubleshooting Question

Add button to docked toolbar on Word document open

Avatar of Barry Tice
Barry TiceFlag for United States of America asked on
Microsoft Office
13 Comments1 Solution887 ViewsLast Modified:
I've added a macro to a Word template, and have the following code in place to access it:

==== BEGIN PASTE ====
Sub AutoNew()

Dim myBar As CommandBar
Dim myControl As CommandBarButton
Dim cmd As CommandBar
For Each cmd In CommandBars
    If = "BarryToolbar" Then
        CommandBars("BarryToolbar").Visible = True
        Exit Sub
    End If

Set myBar = CommandBars.Add( _
        name:="BarryToolbar", _
        Position:=msoBarPopup, _
        menubar:=True, _

Set myControl = CommandBars("BarryToolbar").Controls.Add( _
        Type:=msoControlButton, _

With myControl
    .OnAction = "SubroutineToCall"
    .FaceId = 0
    .Caption = "Perform Barry's Action"
    .TooltipText = "Click the button to perform Barry's action"
    .DescriptionText = "PerformBarry'sAction"
    .Style = msoButtonCaption
End With

CommandBars("BarryToolbar").Visible = True

End Sub
===== END PASTE =====

This does a great job of creating a floating toolbar with one button on it, and the button works great when clicked. But if the first thing the user does is close the floating toolbar to get it out of the way, they have to know to go to the View -> Toolbars menu to get it back. Many of my users aren't that quick.

What can I do to get the toolbar to appear not as a floater, but docked, up with the other docked toolbars, at the top?

I've tried setting the myBar.Position to msoBarTop (and left, and bottom, and right), but nothing seems to change where it appears -- as a floater somewhere over my document.

Any assistance would be most appreciated.

-- b.r.t.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros