如何用vba批量删除ppt幻灯片中同类型的所有图形?

在ppt中,一切皆图形。

有时候我们需要批量删除指定形状的图形,可以使用如下的vba代码:

Sub QQ1722187970()
    Dim oPPT As Presentation
    Dim oSlide As Slide
    Dim oCL As CustomLayout
    Dim oP As Shape
    '当前ppt演示文稿
    Set oPPT = PowerPoint.ActivePresentation
    With oPPT
        '遍历每一个幻灯片
        For Each oSlide In .Slides
            With oSlide
                '遍历每一个图形
                For Each oP In .Shapes
                    With oP
                        sName = .Name
                        iType = .Type
                        '批量删除所有椭圆形
                        If sName Like "*椭圆*" Then
                            .Delete
                        End If
                    End With
                Next
            End With
        Next
    End With
End Sub
       

仅有1条评论 发表评论

  1. James /

    Sub deleteShape()

    ActivePresentation.Slides(1).Shapes.SelectAll
    ActiveWindow.Selection.Delete

    End Sub

发表评论