【问题标题】:Delete all Images on one Slide with VBA in PowerPoint在 PowerPoint 中使用 VBA 删除一张幻灯片上的所有图像
【发布时间】:2019-11-10 08:03:08
【问题描述】:

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

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

Sub DeleteAllPictures()

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

End Sub

使用以下代码添加图像:

    Sub InsertPic_EAP()
  'Insert Picture
 ActivePresentation.Slides(1).Shapes.AddPicture FileName:="U:\Automatisierung\3D_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

如何修改代码以仅选择和删除幻灯片上的图像。

【问题讨论】:

    标签: vba image powerpoint


    【解决方案1】:

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

    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
    

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

    【讨论】:

    • 运行代码时没有任何反应。 ://
    • 你确定幻灯片是第一张幻灯片吗??上面还有图片?
    • 我确定。也许问题是图片添加了一个宏: Sub InsertPic_EAP() 'Insert Picture ActivePresentation.Slides(1).Shapes.AddPicture FileName:="U:\Automatisierung\3D_Module\EAP.png", _ LinkToFile:= msoTrue, _ SaveWithDocument:=msoTrue, Left:=260, Top:=110, _ Width:=270, Height:=250 ... 等等。
    • 答案中的宏应该会删除这些图像。可以分享一下幻灯片吗?
    • 我又试了一次,对于正常添加的图片,代码是完美的。但是我使用宏添加的图像仍然保留在幻灯片上。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多