Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set GIF or JPG transparent color in VBA

331 views
Skip to first unread message

Vincent Verheul

unread,
Nov 3, 2009, 2:18:43 AM11/3/09
to
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


Steve Rindsberg

unread,
Nov 3, 2009, 10:43:19 AM11/3/09
to
Hi. FWIW, JPG doesn't support transparency, so that's out, but GIF and PNG do.

Irfanview can do batch conversions and lets you set a transparent color for
PNG/GIF files (by specifying an RGB value), and can do all this from the
command line. You could use VBA to invoke it to do the heavy lifting.


==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/


Vincent Verheul

unread,
Nov 4, 2009, 7:45:15 AM11/4/09
to
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

"Steve Rindsberg" <ab...@localhost.com> wrote in message
news:VA.0000540...@localhost.com...

Luca Brasi

unread,
Nov 10, 2009, 3:37:02 AM11/10/09
to
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


"Vincent Verheul" wrote:

> .
>

0 new messages