Initial position of floating toolbar

O

Otto Moehrbach

Excel XP & Win XP
I got some code from VBAExpress.com to create a floating toolbar on file
opening and it works well.
My problem is that the sheet that is on the screen is a busy sheet and the
initial position of the toolbar can easily bury the toolbar in the sheet
clutter. I would like to specify the initial position of the toolbar, then
the user can move it as he wishes.
How can I specify the initial position of the tool bar? The toolbar is
Commandbars("My Toolbar").
Thanks for your time. Otto
 
C

Chip Pearson

Try something like the following. The command bar will be on the same row as
the Standard command bar. Commented code shows how to place it on the first
or last row of command bars.

Sub AAA()
Dim CmdBar As Office.CommandBar
Dim Ctrl As Office.CommandBarButton

On Error Resume Next
Application.CommandBars("Test").Delete
On Error GoTo 0
Set CmdBar = Application.CommandBars.Add(Name:="Test", Position:=msoBarTop)
'CmdBar.RowIndex = msoBarRowFirst ' or msoBarRowLast
CmdBar.RowIndex = Application.CommandBars("Standard").RowIndex
CmdBar.Visible = True
Set Ctrl = CmdBar.Controls.Add(Type:=msoControlButton)
Ctrl.Caption = "Click Me"
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 

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