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

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,786
Office Version
  1. 2016
Platform
  1. Windows
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
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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
 
Upvote 0
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 ...
 
Upvote 0
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?
 
Upvote 0
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...
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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
Back
Top