Bad image quality with using CommandBars.GetImageMso when assigning a new image for Access 2021

jacky Perpète 41 Reputation points


For a project with Access 2021, I am displaying office 2021 MSO images in gallery controls of a custom ribbon.
The names of MSO images are contained in a table.
From the 'GetItemImage' event of the custom ribbon, I extract the image name from the table and with the 'GetImageMSO' function of 'Commandbars', I assign the image to the different gallery items.

Public Sub RibbonPrincipal_GetItemImage(control As IRibbonControl, index As Integer, ByRef image)  
'Attribue l'image MSO  
Set image = CommandBars.GetImageMso(rst!ImageMSO, 32, 32)  

The attribution of MSO images works correctly.

The only issue is the quality of some images displayed in custom ribbon gallery items using 'GetImageMSO' versus assigning the same MSO image to ImageMSO in the XML of a control of that same ribbon.
Examples of bad qualities:
Images displaying numbers or letters (_0, _1, ... , A, B, ..) are illegible.
The color of the contour lines are not always identical.
Some colors are not always the same.
The following images show these differences.

Attribution by 'GetImageMSO' of the MSO image (Degraded images)

Assigning ImageMSO property of MSO image in XML (Correct Images)

<gallery id="gallery1" imageMso="AppointmentColor1" itemHeight="32" itemWidth="32" size="large">
<item id="item1" imageMso="_0"/>
<item id="item2" imageMso="_3DExtrusionDepth144Classic"/>
<item id="item3" imageMso="_3DLightingClassic"/>
<item id="item4" imageMso="AdpDiagramAddRelatedTables"/>

Y-a-t-il une solution pour corriger ce problème?

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
799 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. jacky Perpète 41 Reputation points


    I just noticed that the quality of the images changes depending on the Office theme.
    The images corresponding to my question are illustrated with the color theme.

    Here is an illustration with other Office themes

    Black Theme.

    White Theme.

    0 comments No comments

  2. 志伟 林 1 Reputation point

    I had the same issue when I develop an addin for PowerPoint by VSTO.
    It seems the prototype of the "GetItemImage" callback is incorrect in the document. The implementation in the Microsoft.Office.Tools.Common.Implementation.Dll is object GetItemImage(IRibbonControl control, int index). It means that we can take a ID of the build-in image as the result instead of a IPictureDisp object when we want to use the build-in image. The icon will be display normally in the way.

  3. jacky Perpète 41 Reputation points


    Regarding the modification of MSO images with the theme, it is completely normal.

    For an MSO image, I see there are 2 different images displayed depending on the office theme.

    Dark gray and black theme


    Colorfull and white theme


    On the other hand, whatever the office theme, extracting the MSO image with the CommandBars.GetImageMso method always creates this image with the colors of the Dark gray or black office theme.

    The extracted image replaced in a ribbon control by the getitemimage or getimage method does not have the colors well suited to the office colorfull and white theme.

    Shouldn't the image be pulled based on the user's office theme?

    For the complete visualization of all MSO images on the ribbon, I have seen some examples. In the XML code, a button or an item is created for each image with the value of the imageMso attribute corresponding to the name of the imageMso. Many lines of code are required.

    Using callback, the ribbon's gallery control can dynamically load images. It's more flexible.

    Unfortunately, you have to extract the MSO images with the CommandBars.GetImageMso method to introduce them into the gallery.

    This is what gives this color problem.

    Is there another way to extract an MSO image?

    Here is a display showing the images extracted by the GetImageMso method with the colorfull office theme. The colors of the extracted image match the office dark gray or black theme.


    Here is a display showing the same colors between images with the dark gray office theme.


    0 comments No comments