CommandBar Resize

P

purple

I have created a floating commandbar with 3 buttons.
When it shows, the shape defaults to 1 button deep by 3
wide. I can change the shape on screen by using the
mouse to show 3 deep by 1 wide but how can I
programatically do this? It's like doing a wrapround,
squeeze the width and increase the height. '.Height'
resizes the buttons ok but does not work on the bar.
I'd appreciate any views.

T.I.A

purple
 
R

Rob Bovey

purple said:
I have created a floating commandbar with 3 buttons.
When it shows, the shape defaults to 1 button deep by 3
wide. I can change the shape on screen by using the
mouse to show 3 deep by 1 wide but how can I
programatically do this? It's like doing a wrapround,
squeeze the width and increase the height. '.Height'
resizes the buttons ok but does not work on the bar.
I'd appreciate any views.

Hi Purple,

If you set the Width property of your command bar to the width of one
button, the buttons should stack automatically. The width of a standard
command bar button is 39, so the following should do the trick:

CommandBars("YourBarName").Width = 39

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm
 
P

purple

Thanks fo rthe reply but I must be missing something. No
matter what value I set it doesn't seem to make any
difference. This is the code I'm using:
Option Explicit
Option Private Module
Sub InstallFloatingMenu()
Dim floatbar, button1, button2, button3


On Error Resume Next
Application.CommandBars("Edit Income
Parameters").Delete
On Error GoTo 0

'Create floating menu bar and set initial position to
avoid editing form
Set floatbar = CommandBars.Add("Edit Income
Parameters", Position:=msoBarFloating)
With floatbar
.Left = 20
.Top = 200
.Width = 39
End With

'Add buttons and properties
Set button1 = floatbar.Controls.Add(msoControlButton)
With button1
.Width = 65
.Style = msoButtonIconAndCaption
.Caption = "Open"
.FaceId = 23
.OnAction = "FrmInitialise"
End With

Set button2 = floatbar.Controls.Add(msoControlButton)
With button2
.Width = 85
.Style = msoButtonIconAndCaption
.Caption = "Minimise"
.FaceId = 317
.OnAction = "FrmMinimise"
End With

Set button3 = floatbar.Controls.Add(msoControlButton)
With button3
.Width = 85
.Style = msoButtonIconAndCaption
.Caption = "Restore"
.FaceId = 316
.OnAction = "FrmMaximise"
End With

floatbar.Visible = True

End Sub

purple
 
P

purple

Hi Rob
Got it. I can only set the width after the bar has been
made visible!! Yeah :) :0

Many Thanks
 
X

x

01/04/2005 21:30:44
Hi Purple,

If you set the Width property of your command bar to the width of one
button, the buttons should stack automatically. The width of a standard
command bar button is 39, so the following should do the trick:

CommandBars("YourBarName").Width = 39

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top