简体   繁体   中英

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? Eg

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM