ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Bar placement (https://www.excelbanter.com/excel-programming/287897-bar-placement.html)

Beto[_3_]

Bar placement
 
Hi, is there a way to control where a newly added bar is going to be
exactly placed. I know you can put it on top, bottom, left, right or
floating... but is there any way to place it besides another existing
toolbar? Right now, when I choose Top, it add's a new line of toolbars
when there is plenty of space to the right of the existing toolbars.

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.


Rob van Gelder[_4_]

Bar placement
 
Beto,

My custom commandbar in this example has a Name of "Rob".

Sub testit()
Dim cbrMy As CommandBar
Dim cbr As CommandBar, lngMaxRowIndex As Long, lngMaxLeft As Long

Set cbrMy = CommandBars("Rob")

For Each cbr In CommandBars
If cbr.Visible And cbr.Position = msoBarTop And Not (cbr.Index =
cbrMy.Index) Then
If cbr.RowIndex lngMaxRowIndex Then
lngMaxRowIndex = cbr.RowIndex
lngMaxLeft = cbr.Left + cbr.Width
ElseIf cbr.RowIndex = lngMaxRowIndex And cbr.Left + cbr.Width
lngMaxLeft Then
lngMaxLeft = cbr.Left + cbr.Width
End If
End If
Next

cbrMy.Position = msoBarTop
cbrMy.RowIndex = lngMaxRowIndex
cbrMy.Left = lngMaxLeft
End Sub


Rob


"Beto" wrote in message
...
Hi, is there a way to control where a newly added bar is going to be
exactly placed. I know you can put it on top, bottom, left, right or
floating... but is there any way to place it besides another existing
toolbar? Right now, when I choose Top, it add's a new line of toolbars
when there is plenty of space to the right of the existing toolbars.

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.




Beto[_3_]

Bar placement
 
Rob van Gelder wrote:

Beto,

My custom commandbar in this example has a Name of "Rob".

Sub testit()
Dim cbrMy As CommandBar
Dim cbr As CommandBar, lngMaxRowIndex As Long, lngMaxLeft As Long

Set cbrMy = CommandBars("Rob")

For Each cbr In CommandBars
If cbr.Visible And cbr.Position = msoBarTop And Not (cbr.Index =
cbrMy.Index) Then
If cbr.RowIndex lngMaxRowIndex Then
lngMaxRowIndex = cbr.RowIndex
lngMaxLeft = cbr.Left + cbr.Width
ElseIf cbr.RowIndex = lngMaxRowIndex And cbr.Left + cbr.Width
lngMaxLeft Then
lngMaxLeft = cbr.Left + cbr.Width
End If
End If
Next

cbrMy.Position = msoBarTop
cbrMy.RowIndex = lngMaxRowIndex
cbrMy.Left = lngMaxLeft
End Sub


Great piece of code. This should get me started to my final needs.

Thanks!
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.


Hi, is there a way to control where a newly added bar is going to be
exactly placed. I know you can put it on top, bottom, left, right or
floating... but is there any way to place it besides another existing
toolbar? Right now, when I choose Top, it add's a new line of toolbars
when there is plenty of space to the right of the existing toolbars.





All times are GMT +1. The time now is 04:12 PM.

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