在EXCEL表中如何做到只删除AutoShape对象,而不删除里面的图片?

如题所述

'点工作表标签,右键,查看代码,复制下面的代码进去,按F5运行即可
Public Sub del()
Dim sht As Worksheet, p As Shape, ar(), n%
For Each sht In Worksheets
    For Each p In sht.Shapes
        If p.Type = 1 Then n = n + 1: ReDim Preserve ar(1 To n): ar(n) = p.Name
    Next p
    If n > 0 Then sht.Shapes.Range(ar).Delete
    n = 0
Next sht
End Sub

追问

还是不行,

追答

我测试了,没问题呀,发表格给我: [email protected]

温馨提示:答案为网友推荐,仅供参考