PDA

View Full Version : Solved: Custom toolbar position



clvestin
10-23-2005, 12:01 PM
I am adding a custom toolbar.
But I get a wierd looking square on the edge of the sheet. I want to dock the toolbar next to the other toolbars-in line, same height and lined up in the toolbar row. The code below is pretty basic-I'm just trying to feel the addition out.
By giving the toolbar a name, that name then appears in the toolbar, making it too high to fit next to the other toolbars. But then I must refer to it subsequently as CommandBars(3). I don't like that-indices have to be remembered.



Sub corr()
Dim mnu As CommandBar
Dim newitem As CommandBarControl
Dim newtool As CommandBarControl

Set mnu = CommandBars.Add(temporary:=True)
With mnu
.Name = "reports"
.Visible = True
.Position = msoBarTop
End With
Set newtool = Application.CommandBars("reports").Controls.Add(Type:=msoControlButton, temporary:=True)
CommandBars("reports").Controls(1).FaceId = 64
newtool.Visible = True

Bob Phillips
10-23-2005, 02:15 PM
Sub corr()
Dim mnu As CommandBar
Dim newitem As CommandBarControl
Dim newtool As CommandBarControl

Set mnu = CommandBars.Add(temporary:=True)
With mnu
.Name = "reports"
.Visible = True
.Position = msoBarTop
.RowIndex = Application.CommandBars("Formatting").RowIndex
Set newtool = .Controls.Add(Type:=msoControlButton)
With newtool
.FaceId = 64
End With
End With

Norie
10-23-2005, 02:26 PM
xld

Nice one! :)

Never heard of RowIndex.

clvestin
10-23-2005, 02:54 PM
rowIndex-Indeed! Thank you