我想在PowerPoint中使用VBA在幻灯片上仅删除图像。
使用给定代码,幻灯片上的所有形状都将被删除。
Sub DeleteAllPictures()
ActivePresentation.Slides(1).Shapes.Range.Delete
End Sub
添加了以下代码的图像:
Sub InsertPic_EAP()
'Insert Picture
ActivePresentation.Slides(1).Shapes.AddPicture FileName:="U:Automatisierung3D_ModuleEAP.png", _
LinkToFile:=msoTrue, _
SaveWithDocument:=msoTrue, Left:=260, Top:=110, _
Width:=270, Height:=250
ActivePresentation.Slides(1).Shapes.AddPicture FileName:="U:AutomatisierungBilder_APEAP_01.png", _
LinkToFile:=msoTrue, _
SaveWithDocument:=msoTrue, Left:=620, Top:=220, _
Width:=270, Height:=115
End Sub
如何修改代码以仅选择和删除幻灯片上的图像。
此代码将适用于您:编辑 - 链接图片
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
如果是图片,则遍历幻灯片中的所有形状并删除。