title: How to embed images in Office file for custom Ribbon
body: <p>I am developing a custom ribbon extension for Excel, in which a control requires different custom images. I managed to use some images located in my filesystem, but I would like to embed these images inside the .xlsm file.
  Is it possible to do it and to reference them from the VBA code that updates the image of the control?</p>
  
  <p>For test purposes, this is the XML that defines my custom ribbon:</p>
  
  <pre><code>&lt;customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="ribbonLoaded"&gt;
    &lt;ribbon&gt;
      &lt;tabs&gt;
        &lt;tab idMso="TabHome" &gt;
          &lt;group id="customGroup1" label="My Group" insertAfterMso="GroupFont"&gt;
            &lt;button id="customButton1" label="Click Me" size="large" onAction="Macro1" getImage="getButtonImage"/&gt;
          &lt;/group&gt;
        &lt;/tab&gt;
      &lt;/tabs&gt;
    &lt;/ribbon&gt;
  &lt;/customUI&gt;
  </code></pre>
  
  <p>And this is the macro that change the image of the <code>customButton1</code> control:</p>
  
  <pre><code>Dim imgIndex As Long
  
  Public Sub getButtonImage(ByVal control As IRibbonControl, ByRef Image)
  Select Case control.ID
    Case "customButton1"
      Set Image = LoadPicture("img" + Trim(Str(imgIndex)) + ".bmp")
      imgIndex = (imgIndex + 1) Mod 2
    End Select
  End Sub
  </code></pre>
  
  <p>I tried to add the bmp files inside the .xlsm and reference them updating the relationships file (.rels), but I don't know how to reference them from VBA and most important, when I open the file with Excel and save it, they are automatically deleted...</p>
  
  <p>Any help is appreciated!</p>