ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adjusting individual icon size in commandbars? (https://www.excelbanter.com/excel-programming/366071-adjusting-individual-icon-size-commandbars.html)

[email protected]

Adjusting individual icon size in commandbars?
 
Hi!

I'm trying to create a commandbar in excel using VBA and it works fine.
It's just that every picture I try to assign to the iconface always
shrinks to a predestined size. It's possible to change the size of the
button itself (using commandbarcontrol.width or height), but not the
image! Anyone got a suggestion?

/David N


Jon Peltier

Adjusting individual icon size in commandbars?
 
The icon size is fixed. The button size can be stretched somewhat, though I
can't remember not using the default.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


wrote in message
oups.com...
Hi!

I'm trying to create a commandbar in excel using VBA and it works fine.
It's just that every picture I try to assign to the iconface always
shrinks to a predestined size. It's possible to change the size of the
button itself (using commandbarcontrol.width or height), but not the
image! Anyone got a suggestion?

/David N




Leith Ross[_623_]

Adjusting individual icon size in commandbars?
 

Hello David,

Here is a technique that works with Excel 2000. Insert the picture you
what displayed as the button face onto the worksheet. Right click the
picture and Copy it.

Now, run the macro that creates your commandbar button and have the
..PasteFace method in the code. Below is a code example for a temporary
command button...


Code:
--------------------

Sub AddButton()

Dim CmdBar As CommandBar
Dim CmdBtn As CommandBarButton

Set CmdBar = Excel.CommandBars("Worksheet Menu Bar")
CmdBar.Controls.Add Type:=msoControlButton, ID:=1, Temporary:=True

Set CmdBtn = CmdBar.Controls(CmdBar.Controls.Count)

With CmdBtn
.Caption = "Test"
.Style = msoButtonIconAndCaption
.Visible = True
.PasteFace
End With

End Sub

--------------------


The copied picture will be resized automatically to fit your button.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=557677


[email protected]

Adjusting individual icon size in commandbars?
 

Leith Ross skrev:

Hello David,

Here is a technique that works with Excel 2000. Insert the picture you
what displayed as the button face onto the worksheet. Right click the
picture and Copy it.

Now, run the macro that creates your commandbar button and have the
.PasteFace method in the code. Below is a code example for a temporary
command button...


Code:
--------------------

Sub AddButton()

Dim CmdBar As CommandBar
Dim CmdBtn As CommandBarButton

Set CmdBar = Excel.CommandBars("Worksheet Menu Bar")
CmdBar.Controls.Add Type:=msoControlButton, ID:=1, Temporary:=True

Set CmdBtn = CmdBar.Controls(CmdBar.Controls.Count)

With CmdBtn
.Caption = "Test"
.Style = msoButtonIconAndCaption
.Visible = True
.PasteFace
End With

End Sub

--------------------


The copied picture will be resized automatically to fit your button.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=557677






Hi!

I tried your code but it doesn't seem to work. The picture shrinks down
to the standard icon size no matter what size the button is. What am I
doing wrong?

/David



All times are GMT +1. The time now is 10:28 AM.

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