Share via

LoadPicture in Access Office Ribbon (Get runtime-error 481 Invalid Picture)

Anonymous
2010-06-07T00:41:08+00:00

Hi:

I'm getting the Runtime-error 481 Invalid Picture no matter if i use a .png, .ico, .bmp file. I'm trying to add a custom image to the office ribbon using access 2007.

I have search a lot of websites regarding how to do it and found the following easy code and also another document that tells that i need to add to the reference of the Microsoft Office 12.0 Object Library what i allready did but same result.

I have the following line code in XML to load the Image:

             <button id="cmdPhysiciansDemographics" label="Physicians Demographics" onAction="Ribbon.PhysiciansDemographics" getImage="getImages" tag"doctor.png"/>

The VBA Code is:

Public Function getImages(control As IRibbonControl, ByRef image)

Set image = LoadPicture(getAppPath & control.Tag)

End Function

Public Function getAppPath() As String

getAppPath = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))

End Function

I will appreciate any help,

Robert

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. Anonymous
    2010-06-07T23:06:04+00:00

    Gunter: I finally have the time to take a look to the sample DB. After i analyse how it works i was able to add my .png images to the sample DB demo tab. Looks a lot of coding compare to the getImages and getAppPath VBA code that i obtained from this same website of the sample DB but it WORKS!!!!!!!!!!!! Now i need to create the binary table and take the necessary modules code and applied to my db application. Thanks a lot for your help. Robert

    1 person found this answer helpful.
    0 comments No comments

8 additional answers

Sort by: Most helpful
  1. Anonymous
    2010-06-07T13:40:08+00:00

    Tom:

    Thanks for the link but what about if i'm using a 144dpi 48x48 pixels (PNG) file? I tried a PNG file from an example database thats uses a cokezero.png image 48x48 and i get the same error. The only difference that i noticed is that instead of LoadPicture the examples uses LoadPicturesGDIP but looks more complicated than using getImages and LoadPicture.

    In another link that i found they mention that LoadPictures does not support (.png) files but dont know if this is true or not i'm still looking specially on microsoft website.

    Thanks

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2010-06-07T05:05:37+00:00

    Hallo rvb2008,

    rvb2008 schrieb folgendes:

    I'm getting the Runtime-error 481 Invalid Picture no matter if i use a .png, .ico, .bmp file. I'm trying to add a custom image to the office ribbon using access 2007.

    I have search a lot of websites regarding how to do it and found the following easy code and also another document that tells that i need to add to the reference of the Microsoft Office 12.0 Object Library what i allready did but same result.

    I have the following line code in XML to load the Image:

                 <button id="cmdPhysiciansDemographics" label="Physicians Demographics" onAction="Ribbon.PhysiciansDemographics" *getImage="getImages" tag"doctor.png"*/>

    The VBA Code is:

    Public Function *getImages*(control As IRibbonControl, ByRef image)

    Set image = LoadPicture(*getAppPath* & control.Tag)

    End Function

    Public Function *getAppPath*() As String

    getAppPath = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))

    >End Function

    http://www.accessribbon.de/en?Access_-_Ribbons:User_Defined_Icons___Pictures_In_Ribbon_Controls

    HTH

    Gunter


    __________________________________________________________

    Access FAQ: http://www.donkarl.com

          http://www.avenius.com -http://www.AccessRibbon.com

    http://www.ribboncreator.com -http://www.ribboncreator2010.com

    0 comments No comments
  3. Anonymous
    2010-06-07T04:07:25+00:00

    There is an 'equals' sign missing from the code between tag and "doctor".

    <button id="cmdPhysiciansDemographics" label="Physicians Demographics" onAction="Ribbon.PhysiciansDemographics" getImage="getImages" tag"doctor.png"/>

    Change tag"doctor.png" to

    tag="doctor.png"

    0 comments No comments
  4. Tom van Stiphout 40,201 Reputation points MVP Volunteer Moderator
    2010-06-07T03:22:32+00:00

    The site where you found this code also says:

    'Only valid picture formats must be used (see OH).

    So you need to read up on the exact formats that are supported. Here is one possible link:

    http://msdn.microsoft.com/en-us/library/dd316921(VS.85).aspx


    -Tom. Microsoft Access MVP

    0 comments No comments