PDA

View Full Version : Problem with GIF and PNG transparency using Export or SaveAs functions.



nl5n
02-28-2008, 10:28 AM
Hi,
I wrote a macro that exports shapes one by one from a powerpoint presentation as PNG (or GIF) files.
My problem is that the transparency is never exported.
Powerpoint exports a white background instead of transparent areas.

I use the following code:


ActiveWindow.Selection.SlideRange.Shapes(1).Select
ActivePresentation.Export path & "\icoppt\" & filename & "." & graphic_type, graphic_type, scalewidth, scaleheight

I also tried by hand to export shapes with the right-click menu : "save as picture". It worked, the transparency was exported.
I then recorded a macro doing this, but when I play the macro, it exports the entire slide with no transparency and not the shapes alone!!!

code of the recorded macro:


ActiveWindow.Selection.SlideRange.Shapes("AutoShape 4").Select
ActivePresentation.SaveAs FileName:="Image3.png", FileFormat:=ppSaveAsPNG, EmbedTrueTypeFonts:=msoFalse
My question is then: How can I get transparency exported (as alpha channel in PNG would be ideal).

Thanks in advance for your answers.

John Wilson
02-28-2008, 01:05 PM
Try something like this


Dim oshp As Shape
Dim sname As String
Set oshp = ActiveWindow.Selection.ShapeRange(1)
sname = oshp.Name
oshp.Export "c:\documents and settings\john\desktop\" & sname & ".png", ppShapeFormatPNG

nl5n
02-28-2008, 03:29 PM
Thanks for your answer,
I had tried this (I just tried it again with your code), but export is not a possible method for a shape.
Anybody else has a clue?

John Wilson
03-01-2008, 05:40 AM
"but export is not a possible method for a shape"

It is you know! What ppt version do you have?

nl5n
03-04-2008, 01:40 PM
You were right.
It seems that it's a hidden method (not suggested by my PPT when typing), but actually possible.

I actually got messed up with the options ppShapeFormatPNG and ppSaveAsPNG which is why I kept on having errors.

Again thanks.

John Wilson
03-05-2008, 06:06 AM
Go to the Object Browser > Right click > Show Hidden members, see if that helps in future