Chris
Chris

Reputation: 75

Powerpoint - Save group as image via VBA

I would like to save a group as a png-Image.

I am able to export an image as a complete slide, but I cannot figure out how to export only a particular group.

This works for a slide:

Private Sub CommandButton1_Click()
    neuerText = TextBox1.Value
    ActivePresentation.Slides(1).Export "C:\bla\" & neuerText & ".png", "PNG"
End Sub

But how to select only a group? E.g.

ActivePresentation.Slides(1).Shapes("Group 1").Export "C:\bla\" & neuerText & ".png", "PNG"

Ideally, the Image would have a transparent background.

Does anyone know how I can do this?

Upvotes: 2

Views: 1375

Answers (1)

BigBen
BigBen

Reputation: 50008

Using the ShapeRange object should work.

Private Sub CommandButton1_Click()
    neuerText = TextBox1.Value

    Dim myGroup As ShapeRange
    Set myGroup = ActivePresentation.Slides(1).Shapes.Range("Group 1")
    myGroup.Export "C:\bla\" & neuerText & ".png", ppShapeFormatPNG
End Sub

Upvotes: 1

Related Questions