Error displaying MSO image in object from GetImageMSO method of CommandBars with Access 2021

jacky Perpète 41 Reputation points
2022-03-17T09:16:55.207+00:00

Hello,

With access 2021 I am trying to display an MSO image of the CommandBars object either in a button or in an image object on a form.

Here is the VBA code used to display the image in a button enter code here.

Private Sub Commande3_Click()  
  
Me.btnEssai.Picture = Application.CommandBars.GetImageMso("Paste", 16, 16)  
  
End Sub  

When I run this code I get the following error:

runtime error '2220'
Microsoft cannot open the file.

184112-erreur.png

If I assign the MSO image to a variable, I do get a value.

184084-espion.png

I was also able to try with Access 2016 which reports the same error.
Where is the problem?

I performed the same test in Excel 2021 with viewing the MSO image in an Image object, it worked fine.

184103-excel.png

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.
824 questions
0 comments No comments
{count} votes

8 answers

Sort by: Most helpful
  1. Oskar Shon 866 Reputation points MVP
    2022-11-14T08:47:55.44+00:00

    aacdb files?
    Funny, I cant use to create form in this format at all...

    260082-acc-no-form.png


  2. Oskar Shon 866 Reputation points MVP
    2022-11-15T09:11:22.573+00:00

    Ok, sorry I wanted to help because I know Excel, Outlook, PP and Word as well but ACC I use as a database only, so I try to check that on my site to agree with you or say that works on my site because that instructions works in Excel without any problems. In fact Application.CommandBars had a commend GetImageMso in ACC then only check is a right way

    So as you mention i create form as you showing me and I do not see any changes in VB Editor. :/

    260436-image.png

    So sorry I cant help you in this moment.


  3. Oskar Shon 866 Reputation points MVP
    2022-11-15T17:28:53.937+00:00

    Yeah, OMG I do it, and I see the same problem.
    I try assigned this image to many controls and to picture object. Deferent error and the same commend. No success.

    260642-image.png

    From hard drive using file path no problem (even without loadpicture() function) so if save GetImageMso as file somehow
    I try and ... failed.
    or you can use Excel to save it as pictures library for your ACC project that 'll work.
    or use couple hidden picture, and replace it using code.