COMMAND BAR - can custom CB height be set???

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,778
Can a custom commandbar height be set? I tried using the following code to do it, but it does not work??<pre>Set DTTM_CB = CommandBars.Add
With DTTM_CB
.Name = "DTTM"
.Enabled = True
.Visible = True
.Height = 20 THIS DOES NOT APPEAR TO WORK ???
.Position = msoBarTop IF YOU USE .ROWINDEX IS THERE A NEED TO USE .POSITION??
.Left = 0
.RowIndex = CommandBars(1).RowIndex + 1 ' puts custom commandbar under the Windows Menu Bar
.Protection = msoBarNoCustomize ' + msoBarNoMove
End With</pre>
This message was edited by em on 2003-02-09 17:21
 

Some videos you may like

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

dk

MrExcel MVP
Joined
Feb 15, 2002
Messages
2,942
Hi,

The commandbar's dimenstions are affected by the height of controls you place on it. For example, I modified your code to add a custom button to the commandbar with a height of 100. See what it does:-

Code:
Sub test()
    Dim DTTM_CB As CommandBar

    Dim cbButton As CommandBarButton

    On Error Resume Next
    CommandBars("DTTM").Delete
    On Error GoTo 0

    Set DTTM_CB = CommandBars.Add
    With DTTM_CB
        .Name = "DTTM"
        .Enabled = True
        .Visible = True


        .Position = msoBarTop   'IF YOU USE .ROWINDEX IS THERE A NEED TO USE .POSITION??
        .Left = 0
        .RowIndex = CommandBars(1).RowIndex + 1   '  puts custom commandbar under the Windows Menu Bar
        .Protection = msoBarNoCustomize   '  + msoBarNoMove

        Stop
        
        'Look at the commandbar in Excel.  It's height is a default height
        
        Set cbButton = .Controls.Add(msoControlButton)
        cbButton.Height = 100
        
        'Look now.  It's height has expanded to fit the button

    End With
End Sub
 

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,778
dk - thnaks will try that in a minute. Is there a way to make a custom commandbar wrap??

I just added a couple of buttons and the bar gives me the little arrows at the end saying there are buttons, but I like to show all the buttons ...
 

rikrak

Active Member
Joined
Aug 21, 2002
Messages
255
em,

Excel2000:
View | Toolbars | Customize, select options tab, deselect option 2 "last used commands first" (not sure, i'm using Dutch version)

Does this help?
 

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,778
dk - rogggg on the bottom size, that worked.

rikrak - the custom bar still not wrapping, but I think last week I ran across something that saud I could wrap text on a button. If I can find it again that mat be a way to shorten the bar...
 

Watch MrExcel Video

Forum statistics

Threads
1,127,875
Messages
5,627,405
Members
416,245
Latest member
Xterminat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top