开发者

Adding Larger Icon On Excel 2007 Ribbon Button

开发者 https://www.devze.com 2022-12-09 22:11 出处:网络
I\'ve got an Excel 2007 VBA sc开发者_运维知识库ript that adds a button to the ribbon, but unfortunately the icon is tiny.I tried several different FaceId\'s, but they all seemed to add tiny icon butto

I've got an Excel 2007 VBA sc开发者_运维知识库ript that adds a button to the ribbon, but unfortunately the icon is tiny. I tried several different FaceId's, but they all seemed to add tiny icon buttons. Is there a way to load in some of the newer 2007 size icons?

Here is a snippet of the code that I've got loaded in ThisWorkbook:

Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton)
With NewButton
     .FaceId = 752
    .TooltipText = "Convert XLS Files to CSVs"
    .OnAction = "XLSTOCSV"

Thanks for any insights about increasing the size of the icon.


Use the NewButton.Height and NewButton.Width to set the size of the button. Other properties can be found here

Hope this helps

EDIT:

Try this:

Set NewButton= .Controls.Add(Type:=msoControlButton, Id:=YourFaceID)

I'm not sure, but that might do the auto sizing for you

EDIT 2:

If it helps, try making a ribon if you are using buttons. The coding is really simple if you know basic XML. An example is this:

<?xml version="1.0" encoding="utf-8" ?> 
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" > 
    <ribbon> 
        <tabs> 
            <tab id="myTab" label="New Tab"> 
                <group id="group1" label="New Buttons"> 
                    <button id="MyButton" label="My Button" imageMso="HappyFace" size="large" onAction="myButton_ClickHandler" /> 
                </group> 
            </tab> 
        </tabs> 
    </ribbon> 
</customUI>

This creates a ribbon that looks like this:

Adding Larger Icon On Excel 2007 Ribbon Button

Simple steps to getting this:

  1. Open a new excel workbook
  2. Save it as an Excel Add In (*.xlam)
  3. Download this freeware: XML UI editor
  4. Paste the code above into it
  5. Save it
  6. Open Excel
  7. Go to Excel Options > Add ins > Go and tick whatever you called your addin
  8. Have fun with that :)

A few notes on the code: The OnAction is the name of the sub in your excell addin that will be called when that button is clicked. The rest is pretty self explanatory

For more info, look here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号