Set GIF or JPG transparent color in VBA

  • Thread starter Thread starter Vincent Verheul
  • Start date Start date
V

Vincent Verheul

Hi Group,

I want to save a document as a GIF or JPG image with a * transparent *
background. I use this GIF in HTML and want to see the background as it is
defined in the style sheet.

In PowerPoint the following code sets the white background color as the
transparent color and saves the slide as a GIF image:

With Pres.Slides(1) ' Pres is the Presentation object
.FollowMasterBackground = False
.Background.Fill.BackColor.RGB = RGB(255, 255, 255)
.Background.Fill.Transparency = 1
.Export "MyDrawing.gif", ppSaveAsGIF
End With

This works fine with PowerPoint 2003, unfortunately *not anymore* with
PowerPoint 2007. Also after the recent Office Service Pack #2. Is there a
place to report this bug to the Microsoft Office team (this discussion
group)?

Now I'm looking for a way to set the transparent color afterwards. I found a
little command line tool called GIFTRANS.EXE which was designed for unix but
also has a DOS version. This program seems to be rather old and gives an
error message 'Unknown Extension 0x00!'.

Is there a way to code this in VBA? Maybe someone has ever attempted to call
the Windows library msimg32.dll for this purpose? Any other ideas on how to
set a color transparent programmatically?

Thanks,
Vincent
 
Hi Steve,

Thanks for pointing me to this very useful tool. Exactly what I was looking
for! Of course JPG does not support transparency, I should have said PNG.
Anyway, this is a good intermediate solution and hopefully one day the
save-as-GIF-with-transparent-color in PowerPoint will work again.

Vincent
 
An alternative solution might be to:

- set the slide background to a specific color (e.g. rgb(255,254,255) )
- do not set any transparency
- export the slide as png
- insert the exported image as shape (method AddPicture)
- set the previously defined background color as transparent color of this
shape
- export this shape as png

The Shape.Export method still seems to support transparency.

Luca
 
Back
Top