Question Which image formats to use with ribbon buttons? (1 Viewer)

ListO

Señor Member
Local time
Today, 19:47
Joined
Feb 2, 2000
Messages
162
I'm trying to add my own images to buttons I'm adding to a custom ribbon in Access 2007.

I've done fine adding .jpg or .bmp images, but I would like to utilize transparencies for these images so they'll look pretty.

Although Microsoft's MSDN information says to use .png files, they don't seem to work: I get a "Runtime Error '481' - Invalid Picture" in the OnLoadImage code if I try to use that format.

If I use a .gif in which I've set a particular color as the transparency color, that image opens and displays, but with the so-called transparency color showing.

Questions:
Do I need to do something differently to use a .png file rather than .jpg? MS recommends it, but it doesn't seem to work.

Is there a better or different image format that I SHOULD be using?

Thanks for the help.
 

Dezirous

Rafi Ahmed
Local time
Today, 23:47
Joined
Jul 8, 2009
Messages
71
Well, GIF is the chipest and lightest format of image which supports transparency. I will suggest you to use adobe photoshop or any advance image editor and and set transp. color to WHITE. It will be better then other color. Just try it.
 

ListO

Señor Member
Local time
Today, 19:47
Joined
Feb 2, 2000
Messages
162
Thanks for the help, but I have tried just what you suggest. Although the .gif images I make have their transparencies set correctly, the transparent colors are not transparent in the ribbon. They are transparent when opened in MS Photo Editor or when viewed as thumbnails in the explorer.
 

ListO

Señor Member
Local time
Today, 19:47
Joined
Feb 2, 2000
Messages
162
Am I the only person here having this problem?

A long internet search reveals a few others out there with similar problems, and a couple of solutions which involve some very complicated coding to force Access to recognize certain colors as transparent.

Have any of you successfully used .png files for ribbon images? Access seems not to recognize that format as valid on my system.

Have any of you successfully used transparency colors with .gif files? My images appear, but with the transparency color showing.
 

Dezirous

Rafi Ahmed
Local time
Today, 23:47
Joined
Jul 8, 2009
Messages
71
Ok........ lets analyze first........ Access cannot recognize PNG format for transparency... If Access is unable to apply transparency with GIF, then is there any grantee that PNG will work as transparent.... if Access supports transparency....... then it work with GIF too..... there could be a simple solution.... capture the color of your button face....... apply this to your image background........ it will look like transparent if you dont change your windows theme......
 

NigelShaw

Registered User.
Local time
Today, 19:47
Joined
Jan 11, 2008
Messages
1,573
Hi

unless in using using animation, I alwUs use png. My access supports the transparency. Infact my ribbonX book advises you use png for the transparency factor in case the theme colours are changed.

Gif are less quality

I'd always use a png
 

Dezirous

Rafi Ahmed
Local time
Today, 23:47
Joined
Jul 8, 2009
Messages
71
Yes, you are right.... but PNG format are use where transparency & shadow are required, and GIF is less quality.... but if you use adobe photoshop to make GIF, it will give you option for quality like 50%, 80% even 100%. Just for try... you can use GIF. The question raises if Access supports transparency, then why it is supporting PNG which is the major format for high quality image? I'll advise you to use GIF just for your current ribbon.
 

NigelShaw

Registered User.
Local time
Today, 19:47
Joined
Jan 11, 2008
Messages
1,573
Hi Dez,

couple of things here

but if you use adobe photoshop to make GIF, it will give you option for quality like 50%, 80% even 100%
not everybody has photoshop or wants to spend that amount.

The question raises if Access supports transparency, then why it is supporting PNG which is the major format for high quality image?
this doesnt make any sense......

am i also right in saying that in order to use GIF, you need the Gif89.dll as a control on your form?

lastly, PNG is a bigger player in the image world. most programs will create a png as it is becoming an industry standard whereas Gif is a bit a old nowadays. they are poorer quality without a shadow of a doubt :)



nigel
 

Dezirous

Rafi Ahmed
Local time
Today, 23:47
Joined
Jul 8, 2009
Messages
71
Hi Nigel;

not everybody has photoshop or wants to spend that amount.
Well don't think about everybody, just think about your work. If you don't have Adobe Photoshop and don't want to spend money, then you can download trial version then you would be able to do this.

this doesnt make any sense......
If access supports transparency and not supports PNG then it is not the matter of transparency... it's just about Image Format... its means Access only supports BMP and GIF, whether it has transparency or not. Does it make any sense now...? :cool:

am i also right in saying that in order to use GIF, you need the Gif89.dll as a control on your form?
There is an ActiveX for PNG you can try... http://www.libpng.org/pub/png/pngaptk.html it could help you.

lastly, PNG is a bigger player in the image world. most programs will create a png as it is becoming an industry standard whereas Gif is a bit a old nowadays. they are poorer quality without a shadow of a doubt
You are right, if you really want to use only PNG, then you can insert PNG as image, and use it instead of buttons because images also have event procedure...

Hope any suggestion may help you...:)
 

NigelShaw

Registered User.
Local time
Today, 19:47
Joined
Jan 11, 2008
Messages
1,573
Hi

you are making a futile point!

Access already supports png and the transparency involved in png!

To offer advice, you have to think on what the user doesn't have. A bit like me advising someone-

"to get to London really fast, just hop into a ferarri and put your foot down"

not everyone has a ferarri but it will definately get you there fast!

the point is, most people don't have Photoshop so a solution should be offered that maybe doesn't include this like-

"you could use Gimp, or Paint net which are both free".

Access doesn't support png in the standard buttons if this is your reference but as the user was specifically talking about ribbon images,
this IS supported using png files without the use of activeX.

Nigel
 

darbid

Registered User.
Local time
Today, 20:47
Joined
Jun 26, 2008
Messages
1,428
Am I the only person here having this problem?
ListO have you still got a problem?

How are you currently adding the button?

I have ZERO experience with Access 2007 but have gone through this process with adding my one transparent image in 2003.

I am aware of three methods to add transparent images, but for me only Nr.3 worked properly and I think is the only one of these that you can use with VBA the others would need VB6

Method 1 http://support.microsoft.com/kb/288771 (in some languages)

Method 2 http://www.codeguru.com/vb/gen/vb_general/idelanguage/article.php/c3237

Method 3
Code:
Dim myOCB As Office.CommandBar
Dim myOCBBTools As Office.CommandBarPopup
Dim myPIC As stdole.IPictureDisp
Dim myMASK As stdole.IPictureDisp

Set myPIC = LoadPicture("path to your image")
Set myMASK = LoadPicture("path to your mask image")
Set myOCB = Application.CommandBars("Menu Bar")
Set myOCBBTools = myOCB.Controls("&Tools")

[color=darkgreen]'<ADD A NEW BUTTON>[/color]
Set myOCBBCustom = myOCBBTools.Controls.Add(msoControlButton, 1, , , True) 

With myOCBBCustom                                                        
    .Caption = "Hello"
    .Enabled = True
    .Picture =  myPIC
    .Mask = myMASK
    .Visible = True
End With

'myOCB.Reset '<TO RESET THE COMMANDBAR>

Does this look familiar to you.

To get your masked image open your .bmp image in paint and just make any non-transparent part of the image black.
 

NigelShaw

Registered User.
Local time
Today, 19:47
Joined
Jan 11, 2008
Messages
1,573
Hi,

here is a ribbon example XML-
Code:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
   onLoad="rxIRibbonUI_onLoad">
   <ribbon startFromScratch="false">
    <tabs>
     <tab 
      id="rxtab" 
      label="My Custom Tab" 
      insertBeforeMso="TabHomeAccess">

      <group
       id="rxgrp"
       label="Custom Group">

       <toggleButton
        id="rxtgl"
        label="Custom Button" 
        [COLOR="Red"]getImage="rxtgl_getImage"[/COLOR] 
        size="large"
        onAction="rxtgl_Click" />

      </group>
     </tab>
    </tabs>
   </ribbon>
</customUI>
the line in red is the part that gets the image. it calls the GetImage routine to collect and place the image when the ribbon starts.

i have also attached a sample db that will show how this works. you will need to import both modules from the example into your db if you want to use this method.
The example is on a toggleButton but the same method of getting the image is similar, you just need to remove the "If" scenario for the OnClick request.

Hth


Nigel
 

Attachments

  • Ribbon GetImage Example.zip
    177 KB · Views: 801

Acke

Registered User.
Local time
Today, 20:47
Joined
Jul 1, 2006
Messages
158
Hi,

Sample database NigelShaw posted works perfectly on 2016 office machine. Not working on 2010 office computer.

Checked preferences, the same set active on both computers.

I am receiving the follwing message: "Microsoft Access cannot run the macro of callback function >name of the function<. Make sure the macro or function exists and takes the correct parameters."

Image does not apear on the button as it should.

What should I do to make it work on 2010 office device?

Thanks!
 

NigelShaw

Registered User.
Local time
Today, 19:47
Joined
Jan 11, 2008
Messages
1,573
Hi,

Sample database NigelShaw posted works perfectly on 2016 office machine. Not working on 2010 office computer.

Checked preferences, the same set active on both computers.

I am receiving the follwing message: "Microsoft Access cannot run the macro of callback function >name of the function<. Make sure the macro or function exists and takes the correct parameters."

Image does not apear on the button as it should.

What should I do to make it work on 2010 office device?

Thanks!

Hey

Most likely problem is the file referencing as 2010 is older than 2016 and might not have the required files that 2016 has natively.

Take a look at the references in VBA to see if anything is missing and then either download it or get it from your 2016 machine.

Let me know how you get on


Cheers

Nigel
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:47
Joined
May 7, 2009
Messages
19,169
did you add Reference to Microsoft Office XX.X Object Library?
 

Acke

Registered User.
Local time
Today, 20:47
Joined
Jul 1, 2006
Messages
158
Thanks guys and sorry for the slow response.

I've checked the references. The only difference in references is that on the machine where it works, the name of the reference is "Microsoft Office 16.0 Object Library" while on the other it is "Microsoft Office 14.0 Object Library". The same is for "Microsoft Access 14.0/16.0 Object Library" and "Microsoft Office 14.0/16.0 Access Database engine Object Library"

Can the difrence in reference versions be causing the problem?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:47
Joined
May 7, 2009
Messages
19,169
here is the fix
 

Attachments

  • Ribbon GetImage Example.zip
    96.4 KB · Views: 134

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:47
Joined
May 7, 2009
Messages
19,169
you're welcome!
 

Users who are viewing this thread

Top Bottom