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.

 

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:

19.01.2013
Update Downloads for "Trusted Locations" - Versions for Office 2013 ...


29.08.2012
Revised versions for IDBE RibbonCreator2010 (Version 1.1014a) ...

07.08.2012
Update Group Attributes and Callbacks. ...

02.08.2012
New Access FAQ added. New Download added. ...

 

Last update:
April 07, 2013, 22:24