Docking a Toolbar and having it stay

A

Access101

I've created a wonderful custom toolbar and ADd-in using the instructions at
this web site in XL 2003: http://www.contextures.com/xlToolbar02.html

However, the custom toolbar always free floats, even if I drag it up and
dock it, save the XLA, save the code window, save my soul.

Any way to get it to stay put so when I open xl again, it's up at the top
with the other toolbars?
 
D

Dave Peterson

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


You can change this portion:
.Position = msoBarFloating
to
.Position = msoBarTop
or
.Position = msoBarBottom
 
A

Access101

Dave, all of this works great. However, is there a way to dock it to the
right of another toolbar, which itself only takes up half the line, and this
way, it would take up the other half of the row?

If I dock it at Top, the rows are Menus, Standard, Formatting, MyToolbar

If I use Left/Top coordinates and free floating, I can get it to the right
of Standard.

And if I manually move the toolbar and close XL, it's back to its fourth row
position again when I open up XL.

Any help is appreciated.
 
D

Dave Peterson

myToolbar is the row where the new toolbar should be docked?

Dim OtherCmdBar as application.commandbar
set othercmdbar = application.commandbars("mytoolbar")
with application.commandbars.add
.name = toolbarname
.rowindex = othercmdbar.rowindex
.position = msoBarTop
'you could even move it over a bit if you wanted a gap:
.left = othercmdbar.left + othercmdbar.width + 12 'or whatever you want.
End with

Untested. Uncompiled. Watch for typos!
 
D

Dave Peterson

But do use:

Dim OtherCmdBar As CommandBar



Dave said:
myToolbar is the row where the new toolbar should be docked?

Dim OtherCmdBar as application.commandbar
set othercmdbar = application.commandbars("mytoolbar")
with application.commandbars.add
.name = toolbarname
.rowindex = othercmdbar.rowindex
.position = msoBarTop
'you could even move it over a bit if you wanted a gap:
.left = othercmdbar.left + othercmdbar.width + 12 'or whatever you want.
End with

Untested. Uncompiled. Watch for typos!
 
A

Access101

Dave,

Thanks for your ideas. I'm debugging as I go. Since I'm getting errors on
the Dim and the Set commands, I thought I would just try Row =2 and Left =
800.

Although this puts my toolbar on row 2 and over 800 pixels, it still is on a
separate line than other toolbars. Should this be working, or do I need to
get the Dim and Set commands to work in order to a ccomplish this?

Thanks for your time and effort, and suggestions.

Dave Peterson said:
But do use:

Dim OtherCmdBar As CommandBar
 
A

Access101

Dave, Oh wait, I figured it out. I did the following:

Set OtherCmdBar = Application.CommandBars("Standard")

Great advice, thanks so much for your time. This has been very useful.

Dave Peterson said:
But do use:

Dim OtherCmdBar As CommandBar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top