2015年11月30日 星期一

EXCEL VBA 刪除所有圖片物件


Sub DeleteAllPicture()
    Dim myShp  As Shape
    Dim mySht1 As Object
    Dim mySht2 As Worksheet
    Dim myWd   As Window
    Set myWd = ActiveWorkbook.Windows(1)
    For Each mySht1 In myWd.SelectedSheets
        If mySht1.Type = xlWorksheet Then
            Set mySht2 = mySht1
            For Each myShp In mySht2.Shapes
                If myShp.Type = 13 Then
                    myShp.Delete
                End If
            Next
        End If
    Next
    Set mySht1 = Nothing
    Set mySht2 = Nothing
End Sub
張貼留言

LinkWithin

Related Posts Plugin for WordPress, Blogger...

熱門文章