You are here:   Home > Access - Ribbons > User Defined Icons / Pictures In Ribbon Controls

User Defined Icons / Pictures In Ribbon Controls

You can use your own icons an pictures in Ribbon Controls. Instead of the callback imageMSO="xxx" you require "getImage" in Ribbon XML.




The Sample DB contains the function "getAppPath()" which is used to return the database folder and name, where also the icons and pictures are stored. File name including extension has been stored in attribute "tag" in the XML file.

Ribbon XML Synax:

<button id="MyButton"
        label="My Button"
        size="large"
        getImage="getImages" 
        tag="ga.ico"
        onAction="MyButtonCallbackOnAction" />

 

There are two options for callback "getImages" to load user-defined pictures:

Either with build-in Access functions (no transparency) :

Public Sub getImages(control As IRibbonControl, _
                     ByRef image)
' Loads a picture without transparency into the ribbon
' Only valid picture formats must be used (see OH).
   
    Set Image = LoadPicture(getAppPath & control.Tag)
   
'Or a ImageMso 
    image = "HappyFace" 
End Sub


or with GDI+ (the module "basGDI" is required. Transparency and multiple picture formats supported).

Public Sub getImages(control As IRibbonControl, _
                     ByRef image)
' Loads a picture with transparency into the ribbon
' The modul basGDI is required.
 
    Set image = LoadPictureGDIP(getAppPath & control.Tag)
'Or a ImageMso 
    image = "HappyFace" 
End Sub

Required Functions:

Additional function to be copied to a standard module:

Public Function getAppPath() As String     
' Returns the current database folder         
   getAppPath = Left(CurrentDb.Name, Len(CurrentDb.Name) _         
                - Len(Dir(CurrentDb.Name)))     
End Function

Module basGDI required for second example:

You can find this module in Sample DB 3 or the the module for Access 2007, Access 2010 x86, Access 2010 x64, Access 2013 x86 and Access 2013 x64.

 

The module originates from: Sascha Trowitzsch (German) .You can also load it from there. Otherwise you can adjust the sample project from ActiveVB.



 

Last Updates:

18.03.2021
New Download added. ...

25.10.2018
Update Site "Trusted Locations" ...

22.10.2018
New Download added. ...

08.04.2018
IDBE RibbonCreator 2016 (x86 and x64) for Office 2013 and Office 2016 - new release. ...

 

Last update: