ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help with command bar positioning (https://www.excelbanter.com/excel-programming/304710-help-command-bar-positioning.html)

rogervand

help with command bar positioning
 
I have been successful in creating a custom commandbar with the button
I need. I would like to place the custom commandbar on the end of th
built in commandbars at the top of my window. I can get it up there
but it seems to want to live on a line all by itself. I've been usin
the following command:

commandbars("custom").rowindex = 2

It puts my bar where I want it, but moves the builtins down a row. An
advice out there?

Thanks,
Roge

--
Message posted from http://www.ExcelForum.com


Bernie Deitrick

help with command bar positioning
 
Roger,

You need to se the .Left and .RowIndex of your new commandbar based on an
existing commandbar. See the code example below.

HTH,
Bernie
MS Excel MVP

Sub AddSecondCommandbarAfterFirst()
Dim myBar1 As CommandBar
Dim myBar2 As CommandBar

On Error Resume Next
Application.CommandBars("NewCBName").Delete

Set myBar1 = Application.CommandBars("OldCBName")
Set myBar2 = Application.CommandBars.Add("NewCBName")

With myBar2
Set myButton = myBar.Controls.Add(Type:=msoControlButton, ID:=23)
With myButton
.Caption = "This or that"
.Style = msoButtonIcon
.FaceId = 137
End With
.Position = msoBarTop
.Left = myBar1.Width
.RowIndex = myBar1.RowIndex
.Visible = True
.Enabled = True
End With

End Sub


"rogervand " wrote in message
...
I have been successful in creating a custom commandbar with the buttons
I need. I would like to place the custom commandbar on the end of the
built in commandbars at the top of my window. I can get it up there,
but it seems to want to live on a line all by itself. I've been using
the following command:

commandbars("custom").rowindex = 2

It puts my bar where I want it, but moves the builtins down a row. Any
advice out there?

Thanks,
Roger


---
Message posted from http://www.ExcelForum.com/




rogervand[_2_]

help with command bar positioning
 
Thanks for the help Bernie. I stumbled across the solution a few minute
after posting. I was able to set the position relative to th
"Standard" command bar

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 08:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com