Excel vba刪除工作簿上所有shape形狀

2019-11-05 16:21:00
tmtony8
原創
82

如果錶格中有多箇shape形狀,如果需要全部刪除,是否有更好的辦法?


下麵代碼遍歷整箇工作簿,逐箇工作錶批量刪除所有形狀對象

Public Sub Del_Shapes()
    Dim sht As Worksheet
    Dim p As Shape
    Dim arr(), n%
    For Each sht In Worksheets
        For Each p In sht.Shapes
            If p.Type = 1 Then n = n + 1
            ReDim Preserve arr(1 To n):
            arr(n) = p.Name
        Next p
        If n > 0 Then sht.Shapes.Range(arr).Delete
        n = 0
    Next sht
End Sub



刪除結果

    分享