Add Ribbon Shortcut Icon To Call VBA Macro In Document level

Overview

Just add an xml file for a new tab containing a button and register the xml file in the .rels xml file inside the Excel file.

learn.microsoft.com::Customize the Office Fluent ribbon by using an Open XML formats file

Additional Description

I’m not sure if it’s because it’s a Korean document, but when I specified the function name in xml as ThisDocument.SomeFunctionName, it was not called.

It worked After I added a module to the document as shown below and called the function name of the module directly.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> 
   <ribbon> 
     <tabs> 
       <tab id="CustomTab" label="My Tab"> 
         <group id="SampleGroup" label="Sample Group"> 
           <button id="Button" label="HelloWorld Label" size="large" onAction="HelloWorld" /> 
         </group > 
       </tab> 
     </tabs> 
   </ribbon> 
 </customUI>

It was an Excel file I created a few years ago to automate tasks, but I couldn’t remember how I added the buttons, so I had to spend some time. I’m leaving a note for your future self.

I considered using Visual Studio Tools for Office, but I thought it would complicate security-related issues, so I wanted to use a simpler method.

I think that my future self will probably want to see the following again.

tags