+ Reply to Thread
Results 1 to 5 of 5

Displaying custom ribbon image using callback

  1. #1
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,060

    Displaying custom ribbon image using callback

    I have this ribbon callback to deterimine the image of a button. As shown it's using the inbuild mso images, which works.

    Please Login or Register  to view this content.
    However, instead of using an mso image I want to use a custom image called "MyImage" that I've added to the XML.
    I've tested that MyImage works when hard-coded into the XML, but when trying to set returnedVal = "MyImage" no picture shows.

    So in this example, if a = b then no image is shown when it should show the custom image.
    Please Login or Register  to view this content.
    Last edited by ByteMarks; 04-25-2025 at 06:17 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,007

    Re: Displaying custom ribbon image using callback

    As I recall, the only method Ron de Bruin ever had for this was extracting the images from an unzipped copy of the file and then loading them from disk. There didn't appear to be any way to simply refer to embedded ones directly.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,060

    Re: Displaying custom ribbon image using callback

    I did it using GDI+ and having the images in a separate folder, but disappointed that there doesn't seem a way for VBA to reference images within the construct of the file.

    In a module:
    Please Login or Register  to view this content.
    Usage
    Please Login or Register  to view this content.
    Useful info here too
    Last edited by ByteMarks; 04-25-2025 at 07:59 AM.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,542

    Re: Displaying custom ribbon image using callback

    A simpler workaround to the problem (if that is acceptable) is to prepare two buttons with hard-assigned icons. In turn, the code sets the visibility of the corresponding button. E.g. XML:
    PHP Code: 
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="RibbonOnLoad">
      <
    ribbon>
        <
    tabs>
          <
    tab id="customTab" label="My Tab">
            <
    group id="customGroup" label="My Group">
              <
    button 
                id
    ="myDynamicButton_1"
                
    label="Click Me"
                
    image="MyImage"
                
    getVisible="GetButtonVisible"
                
    size="large"
                
    onAction="MyButtonAction" />
              <
    button 
                id
    ="myDynamicButton_2"
                
    label="Click Me"
                
    imageMso="AnimationOnClick"
                
    getVisible="GetButtonVisible"
                
    size="large"
                
    onAction="MyButtonAction" />
            </
    group>
          </
    tab>
        </
    tabs>
      </
    ribbon>
    </
    customUI
    Of course, the MyImage icon is stored in an XML file.

    VBA:
    Please Login or Register  to view this content.
    Artik

  5. #5
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,060

    Re: Displaying custom ribbon image using callback

    Thanks Artik, that's a good workaround.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. 'Invalid image error :481' when displaying 7 charts or more as image
    By djemy1975* in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2018, 02:26 AM
  2. Put VBA ribbon together with Custom UI Editor Ribbon
    By czarlando in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2016, 05:46 AM
  3. Assistance with Custom Tab and Groups on Excel Office Ribbon using Custom UI Editor.
    By sdavison in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-15-2015, 06:13 AM
  4. [SOLVED] An alternative to the Add-Ins ribbon tab - Global Custom Ribbon Tab by Ken Puls
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-16-2014, 10:01 PM
  5. [SOLVED] Callback for Ribbon drop down
    By icyrius in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2013, 04:28 PM
  6. Displaying and Updating Image Dynamically (ActiveX Image Control?)
    By VTHokie11 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2011, 10:57 AM
  7. [SOLVED] Hyperlink to an image in other worksheet, displaying entire image.
    By twilliams in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-07-2006, 06:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1