4

次の VBA マクロを使用して、PowerPoint スライドのすべての画像を削除しています。

Public Function delete_slide_object(slide_no)
     ' Reference existing instance of PowerPoint
    Set PPApp = GetObject(, "Powerpoint.Application")
     ' Reference active presentation
    Set PPPres = PPApp.ActivePresentation
     ' Delete object in slide
    Set PPSlide = PPPres.Slides(slide_no)
    For Each PPShape In PPSlide.Shapes
        If PPShape.Type = msoPicture Then
            PPShape.Delete
        End If
    Next PPShape

    Set PPShape = Nothing
    Set PPSlide = Nothing
    Set PPPres = Nothing
End Function

このコードはすべての写真ではなく一部を削除しています。このコードを 3 回実行すると、すべての写真が削除されます。どこが間違っているのですか?教えてください

4

1 に答える 1