使用場景:比如logo圖片不是在ppt幻燈片母版插入的,而是在每張ppt的右下角作為前景圖片插入的,那么一張張刪除的話工作量巨大,所以需要批量刪除。
步驟:
1、首先打開需要編輯的PPT幻燈片,點擊打開視圖中的“宏”:

2、然后在彈出來的窗口中輸入一個宏名,選擇宏作用于當(dāng)前ppt還是所有打開的ppt,然后點擊“創(chuàng)建”。

3、然后在彈出來的窗口中復(fù)制粘貼以下的代碼(注意:窗口默認帶有的代碼全部不要):
Sub Test() Dim oSlide As Slide, oShape As Shape Dim myWidth As Single, myHeight As Single, myTop As Single, myLeft As Single On Error Resume Next If ActiveWindow.Selection.ShapeRange.Count <> 1 Then If Err.Number <> 0 Then MsgBox "none" & vbCrLf & "choose one", vbExclamation + vbOKOnly Err.Clear Exit Sub End If MsgBox "choose exceed 1" & vbCrLf & "choose one", vbExclamation + vbOKOnly Exit Sub End If Set oShape = ActiveWindow.Selection.ShapeRange(1) myTop = oShape.Top myLeft = oShape.Left myHeight = oShape.Height myWidth = oShape.Width For Each oSlide In ActivePresentation.Slides For Each oShape In oSlide.Shapes If Abs(myTop - oShape.Top) < 1 And Abs(myLeft - oShape.Left) < 1 And Abs(myHeight - oShape.Height) < 1 And Abs(myWidth - oShape.Width) < 1 Then oShape.Delete End If Next Next End Sub
如圖:

4、回到 ppt的窗口,先選中需要刪除的圖片,然后點擊“視圖 ”->“宏”,選擇剛才創(chuàng)建的宏,并運行,即可刪除所有相同位置的圖片。
