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:

30.05.2014
Update Downloads for "Trusted Locations" - Versions ...


21.04.2014
Revised versions for IDBE RibbonCreator2013 32 Bit and 64 Bit (Version 1.1007) ...

15.03.2014
Update Site "User Defined Icons / Pictures In Ribbon Controls" ...

12.02.2014
Update FAQ ...

 

Last update:
May 30, 2014, 17:52