ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Commandbar Positioning (https://www.excelbanter.com/excel-programming/347945-commandbar-positioning.html)

PosseJohn

Commandbar Positioning
 
I have a commandbar that is created by VBA code. I want it displayed in a
particular location, with a height and width of my choosing.

Can't figure out the syntax to refer to the commandbar and its properties.

Thankyou in advance.

PosseJohn

Commandbar Positioning
 
I was able to use some of what you provided, but I am not able to change the
height or width of the toolbar to show all the buttons. Any further ideas?

Here is the code I'm running...

With Application.CommandBars.Add
.Name = "FaceID1"
.Left = 30
.Top = 115
.Height = 308
.Width = 903
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating
End With


Rowan Drummond[_3_]

Commandbar Positioning
 
How many buttons are you adding? It is not normally neccessary to size
the toolbar - it will automatically stretch to show all the buttons.

Regards
Rowan

PosseJohn wrote:
I was able to use some of what you provided, but I am not able to change the
height or width of the toolbar to show all the buttons. Any further ideas?

Here is the code I'm running...

With Application.CommandBars.Add
.Name = "FaceID1"
.Left = 30
.Top = 115
.Height = 308
.Width = 903
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating
End With


PosseJohn

Commandbar Positioning
 
I am running a routine that adds face ID's to the toolbar, so that I can
'see' which one I would like to use in/for my apps. I am creating 2 toolbars
that contain 500 buttons each.

I change the .toolbartip to the face ID number, .onaction = xlnone.

Seems extreme, but it allows me to select the face ID's easily.

The .top and .left properties seem to be working, just the .height and
..width are not working at all.


Rowan Drummond[_3_]

Commandbar Positioning
 
There are a number of free addins available that do this already. I use
Jim Rech's BtnFaces which you can get here
http://www.BMSLtd.ie/MVP/Default.htm

The code below from RB Smissaert places all the faceids onto the
activesheet (make sure this is a blank sheet):

'----------------------------------------------------------
Sub ShowAllFaceID()

Dim CBC As CommandBarControl
Dim i As Long
Dim n As Long
Dim c As Long
Dim strSpacer As String
Dim lFaceIDCount As Long
Dim Sh As Shape

Application.ScreenUpdating = False
Application.Cursor = xlWait
strSpacer = "~" & String(3, Chr(32))
Cells.Clear

'get rid of the old FaceID's first
'---------------------------------
For Each Sh In ActiveSheet.Shapes
Sh.Delete
Next

Set CBC = _
CommandBars("Worksheet Menu Bar").Controls.Add(Type:=msoControlButton, _
temporary:=True)

Do
If i Mod 12 = 0 Then
n = n + 1
c = 1
Else
c = c + 1
End If
i = i + 1
On Error GoTo ERROROUT
CBC.FaceId = i
On Error Resume Next
CBC.CopyFace
If Err.Number = 0 Then
Cells(n, c) = strSpacer & i
ActiveSheet.Paste Cells(n, c)
Else
Err.Clear
End If
Application.StatusBar = _
" Dumping all Office FaceID's in sheet, please wait ... " & i
Loop

ERROROUT:
CBC.Delete

With ActiveSheet.DrawingObjects
.ShapeRange.ScaleWidth 1.28, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight 1.28, msoFalse, msoScaleFromTopLeft
Range(Cells(1), Cells(n, 1)).RowHeight = .ShapeRange.Height
End With

Range(Cells(1), Cells(n, 12)).Columns.AutoFit

With Application
.ScreenUpdating = True
.Cursor = xlDefault
.StatusBar = False
End With

End Sub
'---------------------------------------------------------

Hope this helps
Rowan

PosseJohn wrote:
I am running a routine that adds face ID's to the toolbar, so that I can
'see' which one I would like to use in/for my apps. I am creating 2 toolbars
that contain 500 buttons each.

I change the .toolbartip to the face ID number, .onaction = xlnone.

Seems extreme, but it allows me to select the face ID's easily.

The .top and .left properties seem to be working, just the .height and
.width are not working at all.



All times are GMT +1. The time now is 01:26 PM.

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