• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Microsoft Excel Tips and Tricks - Computergaga

  • Home
  • Excel Online Courses
  • Excel Functions List
  • Free Downloads
  • Blog
  • Tutorials
  • About
Home / VBA / Use Own Icon for Macro Button on Ribbon

Use Own Icon for Macro Button on Ribbon

In this blog post, we look at how you can use your own icon or image for the button of your macro on the Ribbon.

This could be an image that you have created, or one that you downloaded from a website.

By using our own icons we can create customised workbooks and not be constrained by the standard Microsoft icon set provided.

In this example, I have a macro that exports all the worksheets of a workbook to PDF, and I want to assign it to the icon shown below. This icon was downloaded from flaticon.com, a fantastic resource for icons that you can use for your macros.

Macro button to add to the Ribbon

Download the Custom UI Editor for Office

To insert our icon into a Ribbon of an Excel file we need the Custom UI Editor for Office. This is free to download and if you do not have it already you can download it here – Custom UI Editor for Office.

Adding your Own Icon to the Ribbon for your Macro

Open the Custom UI Editor and open the Excel workbook where you would like to add your icon.

You may see some XML code appear as soon as you open the file, but you will probably need to insert some sample XML code to get started.

You can do this by clicking Insert, Sample XML and then Custom Tab.

Insert sample XML code

This code can now be edited to work for you. Change the label for the tab, group and then button to what you want to use.

Then enter the name of the image you want to use for the image argument. In the example below my image is saved as analytics-72. Shortly we will insert this into the Excel workbook.
Finally enter the name of your macro for the onAction argument. My macro is called ExportAsPDF.

Code in the Custom UI Editor to add your own macro button

You can copy and paste the relevant lines of code to easily add more buttons, groups or tabs.

Insert your Image to the Workbook

With the code now set to add your icon to the Ribbon and run your macro, we need to insert the image into the workbook so that it is there to be used.

Click the Insert menu and then Icons. Browse and select your icon and it will be added to the file. You can see it on the left. Click the + sign next to the workbook name to expand the list of all added icons.

Own icon added in the Custom UI Editor

Watch the Video

More Excel VBA Tutorials

  • Format specific words in a cell using Excel VBA
  • Using the OnTime method in VBA
  • Excel macro to email a workbook as an attachment

Reader Interactions

Comments

  1. Ken Witchel says

    2 January 2017 at 3:02 pm

    Thank you very much for this tutorial. I have been wanting to do something like this for a while. Your example showed how to add a custom ribbon to a workbook. Could I also create an add-in and use the Custom UI editor to add my own icons? Would I create a new ribbon for PERSONAL.XLSB?

    Reply
    • computergaga says

      2 January 2017 at 7:02 pm

      You can create icons on a Ribbon of a workbook and save it as an add-in for distribution. I have not tried creating one in the PERSONAL.XLSB before but cannot see why this would not work also.

      Reply
      • Ken Witchel says

        3 January 2017 at 5:34 pm

        Thank you for the prompt reply. I have two more questions:
        1. To access Microsoft’s icons, would I leave imageMSO as is?
        2. If I add a ribbon to a workbook, if I then copy the workbook, would the ribbon also be copied. If this is the case, then in certain situations, would this negate the need for a separate add-in?

        Reply
        • computergaga says

          3 January 2017 at 7:58 pm

          1. Yes imageMSO is for the Microsoft icons.
          2. Yes, I believe if you copy the workbook then the Ribbon would be contained with it. I guess this does reduce the advantages of an add-in. An add-in would remain a far more efficient way of distributing macros, or in this case a Ribbon tab though. Especially in a business environment.

          Reply
  2. Gayle says

    6 October 2017 at 11:29 pm

    Hello I love these nice clear instructions so thank you! I want to add a custom image to macros I have written and I want these to appear on the ribbon every time I open a new workbook. I currently have quite a few macros that I have displaying on a custom tab in the ribbon but the standard microsoft icon images don’t match the macro functions well at all 🙁 How would I go about achieving this?

    Reply
    • computergaga says

      7 October 2017 at 4:03 am

      You may be able to follow the steps and add the icon to the Personal.xlsb workbook making it available to new workbooks. I havn’t tried this, the blog post demonstrates adding an icon to a specific workbook, but I’m confident it would work.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Excel SWITCH Function – Nested IF Function Alternative
  • Sum Formulas Only in Excel
  • How to Calculate Age in Excel
  • Custom Sort in Excel
  • Case Sensitive Lookup with XLOOKUP in Excel
Advanced Excel Success book

Footer

Contact

[email protected]

LinkedIn Twitter YouTube

Useful Links

  • Home
  • Excel Online Courses
  • Tutorials
  • Sitemap
  • Privacy Policy
  • Jobs by Jooble

Course Topics

  • Blog
  • Charts
  • Courses
  • Dashboards
  • Downloads
  • Excel Tips
  • Formulas
  • Mail Merge
  • Office
  • PivotTables
  • Power BI
  • Power Pivot
  • Power Query
  • VBA

Join Our Mailing List

© Copyright 2009 Computergaga · All Rights Reserved ·