ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Command Bar position (https://www.excelbanter.com/excel-programming/319437-command-bar-position.html)

Matt Jensen

Command Bar position
 
Howdy
I want my command bar to be positioned what I can only think to call
"opposite to being floating".

Set MYCommandBar = CommandBars.Add(Name:="MyBar", _
Position:=msoBarFloating, Temporary:=True)

what is the oppositite to the above? Is it msoBarTop - where does that put
it relative to the other menus bars that are at the top? I want to add it
above the main window but below all other toolbars.
And what and when is the following code used for:
MenuBar:=True
?

Thanks
Matt



Sharad

Command Bar position
 

Apart from msoBarFloating you can have
msoBarLeft
msoBarRight
msoBarTop
msoBarBottom

mosBarTop will put the command bar at the top just below the menubar.
(The topmost tool bar will be your commandbar).

If you set MenuBar:=True then the existing menubar (where you have File,
Edit, Instert etc. menus) will disappear and your command bar will take
its place if it is msoBarTop.

Sharad



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Matt Jensen

Command Bar position
 
Thanks Sharad
So how do I put my command bar above my worksheet window below the menubar
but below the other command bars there and without replacing any of the
command bars that are there?
Do I just omit the Position property?
Thanks
Matt

"Sharad" wrote in message
...

Apart from msoBarFloating you can have
msoBarLeft
msoBarRight
msoBarTop
msoBarBottom

mosBarTop will put the command bar at the top just below the menubar.
(The topmost tool bar will be your commandbar).

If you set MenuBar:=True then the existing menubar (where you have File,
Edit, Instert etc. menus) will disappear and your command bar will take
its place if it is msoBarTop.

Sharad



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Jim Cone

Command Bar position
 
Matt,

You need to provide the "RowIndex"...

MyCommandBar.RowIndex = Application.CommandBars("Formatting").RowIndex + 1

If the Formatting toolbar is visible, the above code places MyCommandBar
just below the formatting toolbar.
No, you cannot determine the rowindex by just counting the visible toolbars.
Also, you still need msoBarTop.

OR, go thru the CommandBar collection and find the largest rowindex...

Sub TestBar()
Dim MyCommandBar As CommandBar
Dim lngBarIndex As Long

For Each MyCommandBar In Application.CommandBars
If MyCommandBar.Visible Then lngBarIndex = _
WorksheetFunction.Max(lngBarIndex, MyCommandBar.RowIndex)
Next

Set MyCommandBar = CommandBars.Add(Name:="MyBar", _
Position:=msoBarTop, Temporary:=True)
MyCommandBar.RowIndex = lngBarIndex + 1
MyCommandBar.Visible = True
Set MyCommandBar = Nothing
End Sub


Regards,
Jim Cone
San Francisco, USA


"Matt Jensen" wrote in message ...
Thanks Sharad
So how do I put my command bar above my worksheet window below the menubar
but below the other command bars there and without replacing any of the
command bars that are there?
Do I just omit the Position property?
Thanks
Matt



"Sharad" wrote in message
...

Apart from msoBarFloating you can have
msoBarLeft
msoBarRight
msoBarTop
msoBarBottom
mosBarTop will put the command bar at the top just below the menubar.
(The topmost tool bar will be your commandbar).
If you set MenuBar:=True then the existing menubar (where you have File,
Edit, Instert etc. menus) will disappear and your command bar will take
its place if it is msoBarTop.
Sharad



Jim Cone

Command Bar position
 
Matt,

Looks like there is an easier way, using msoBarRowLast...
'--------------------------
Sub TestBarModified()
Dim MyCommandBar As CommandBar

Set MyCommandBar = CommandBars.Add(Name:="MyBar", _
Position:=msoBarTop, Temporary:=True)

MyCommandBar.RowIndex = msoBarRowLast

MyCommandBar.Visible = True
Set MyCommandBar = Nothing
End Sub
'--------------------------

Regards,
Jim Cone


"Jim Cone" wrote in message
...
Matt,
You need to provide the "RowIndex"...
MyCommandBar.RowIndex = Application.CommandBars("Formatting").RowIndex + 1
If the Formatting toolbar is visible, the above code places MyCommandBar
just below the formatting toolbar.
No, you cannot determine the rowindex by just counting the visible toolbars.
Also, you still need msoBarTop.
OR, go thru the CommandBar collection and find the largest rowindex...
Sub TestBar()
Dim MyCommandBar As CommandBar
Dim lngBarIndex As Long
For Each MyCommandBar In Application.CommandBars
If MyCommandBar.Visible Then lngBarIndex = _
WorksheetFunction.Max(lngBarIndex, MyCommandBar.RowIndex)
Next
Set MyCommandBar = CommandBars.Add(Name:="MyBar", _
Position:=msoBarTop, Temporary:=True)
MyCommandBar.RowIndex = lngBarIndex + 1
MyCommandBar.Visible = True
Set MyCommandBar = Nothing
End Sub
Regards,
Jim Cone
San Francisco, USA



Sharad

Command Bar position
 
What do you mean by "Looks Like" Jim?

That's not only the easiest, but the 'Accurately Correct' way! :)

Thanks for me too (Apart from Matt will be thankful)
cheers!

Sharad





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Matt Jensen

Command Bar position
 
Great - thanks a lot guys - looks good
Cheers
Matt

"Jim Cone" wrote in message
...
Matt,

Looks like there is an easier way, using msoBarRowLast...
'--------------------------
Sub TestBarModified()
Dim MyCommandBar As CommandBar

Set MyCommandBar = CommandBars.Add(Name:="MyBar", _
Position:=msoBarTop, Temporary:=True)

MyCommandBar.RowIndex = msoBarRowLast

MyCommandBar.Visible = True
Set MyCommandBar = Nothing
End Sub
'--------------------------

Regards,
Jim Cone


"Jim Cone" wrote in message
...
Matt,
You need to provide the "RowIndex"...
MyCommandBar.RowIndex = Application.CommandBars("Formatting").RowIndex +

1
If the Formatting toolbar is visible, the above code places MyCommandBar
just below the formatting toolbar.
No, you cannot determine the rowindex by just counting the visible

toolbars.
Also, you still need msoBarTop.
OR, go thru the CommandBar collection and find the largest rowindex...
Sub TestBar()
Dim MyCommandBar As CommandBar
Dim lngBarIndex As Long
For Each MyCommandBar In Application.CommandBars
If MyCommandBar.Visible Then lngBarIndex = _
WorksheetFunction.Max(lngBarIndex, MyCommandBar.RowIndex)
Next
Set MyCommandBar = CommandBars.Add(Name:="MyBar", _
Position:=msoBarTop, Temporary:=True)
MyCommandBar.RowIndex = lngBarIndex + 1
MyCommandBar.Visible = True
Set MyCommandBar = Nothing
End Sub
Regards,
Jim Cone
San Francisco, USA






All times are GMT +1. The time now is 10:06 PM.

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