在 PowerPoint 中使用 VBA 删除一张幻灯片上的所有图像

Delete all Images on one Slide with VBA in PowerPoint

我只想在 PowerPoint 中删除带有 VBA 的幻灯片上的图像。

使用给定的代码删除幻灯片上的所有形状。

Sub DeleteAllPictures()

ActivePresentation.Slides(1).Shapes.Range.Delete

End Sub

使用以下代码添加图像:

    Sub InsertPic_EAP()
  'Insert Picture
 ActivePresentation.Slides(1).Shapes.AddPicture FileName:="U:\AutomatisierungD_Module\EAP.png", _
   LinkToFile:=msoTrue, _
   SaveWithDocument:=msoTrue, Left:=260, Top:=110, _
   Width:=270, Height:=250

 ActivePresentation.Slides(1).Shapes.AddPicture FileName:="U:\Automatisierung\Bilder_AP\EAP_01.png", _
   LinkToFile:=msoTrue, _
   SaveWithDocument:=msoTrue, Left:=620, Top:=220, _
   Width:=270, Height:=115

    End Sub

如何将代码修改为仅 select 并删除幻灯片上的图像。

此代码适合您:编辑 - 链接图片

Sub DeleteAllPictures()

Dim shp As Shape

    For Each shp In ActivePresentation.Slides(1).Shapes

    If shp.Type = msoLinkedPicture Then
        shp.Delete
    End If

    Next

End Sub

遍历幻灯片中的所有形状,如果是图片则删除。