ribbon load custom image

Jaye7

Registered User.
Local time
Today, 20:53
Joined
Aug 19, 2014
Messages
205
I have the following xml script in my table and I want to make the 3rd button be a image that is saved in my c drive.

Code:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="onRibbonLoad1">
   <ribbon startFromScratch="true" >
     <tabs>
       <tab  id="FirstTab" label="File" >
         <group id="tab1grp1" label="Print" >
           <button id="btn1" size="large" label="Print" imageMso="FilePrint" onAction="fFunctionNameGeneral"/>
         </group>
         <group id="tab1grp2" label="Print Preview" >
           <button id="btn2" size="large" label="Print Preview" imageMso="FilePrintPreview" onAction="fFunctionNameGeneral"/>
         </group>
  <group id="tab1grp3" label="Test" >
           <button id="btn3" size="large" label="Test" imageMso="HappyFace" onAction="fFunctionNameGeneral"/>
         </group>
       </tab>
     </tabs>
   </ribbon>
  </customUI>
I found the following getimage script but am not sure how to apply it to my button, I have seem various examples on sites but just can't get it to work.
Can I somehow set the icon path like C:\Image1.png


Code:
Public Sub getImages(control As IRibbonControl, _
                                   ByRef image)                
                  Set Image = LoadPicture(getAppPath & control.Tag)    

' Maybe something like           
   ' Set Image = LoadPicture(c:\image1.png)         
              
              End Sub
 
You need to define the getImage callback in the button xml. See how each of your buttons has an imageMso property defined? Remove that 'hard-coded' property value, and add a 'getImage' callback with the name of the routine to run when this data is requested by the system . . .
Code:
<button id=[COLOR="Purple"]"btn3"[/COLOR] size="large" label="Test" getImage=[COLOR="Blue"]"getImages"[/COLOR] onAction="fFunctionNameGeneral"/>
. . . so now that will call your getImages routine. Then I would expect your getImages code to do something more like . . .
Code:
Public Sub [COLOR="Blue"]getImages[/COLOR](irc As IRibbonControl, image)                
   if irc.id = [COLOR="Purple"]"btn3"[/COLOR] then 
      Set image = LoadPicture([I][COLOR="DarkRed"]<specify path to image>[/COLOR][/I])    
   end if
End Sub
Hope this helps,
 
Thanks Mark, it works great, much appreciated.
 

Users who are viewing this thread

Back
Top Bottom