2017-07-25 56 views
0

我目前正嘗試在一張幻燈片上用宏刪除形狀(由用戶繪製的墨跡形狀,並在演示完成時保留)。它看起來像這樣:Powerpoint刪除一張幻燈片的一部分的形狀

Sub EraseInkOnSlide(oSl As Slide) 
' Erases any INK shapes drawn by the user and 
' retained when the user quits the slide show 
    Dim oSh As Shape 
    Dim x As Long 
    With oSl.Shapes 
    For x = .Count To 1 Step -1 
     If .Item(x).Type = 23 Then 
      .Item(x).Delete 
     End If 
    Next 
    End With 
End Sub 

現在我只想要刪除的宏在演示文稿的一部分油墨的形狀,例如,在幻燈片上的一個特定的平方。

這是可能的,如果是這樣怎麼樣?

+0

在刪除項目之前,請添加幾個測試。如果它的.Top和.Left等於或大於.Top和.Left的正方形,並且它的.Top + .Height是= <正方形的.Top + .Height AND如果它的.Left + .Width = <正方形的.Left + .Width然後刪除它。 –

+0

迷人地工作!非常感謝你!也許把它寫成答案,所以我可以將其設置爲最佳工作答案? –

+0

很高興幫助,但更好的是,爲什麼不發佈代碼作爲答案;對於更多的人來說,這應該比我的無恥的建議更有用。 –

回答

0

在史蒂夫的幫助下,我得到了它的工作。這裏是代碼:

Sub EraseInkOnSlide(oSl As Slide) 
' Erases any INK shapes drawn by the user and 
' retained when the user quits the slide show 
Dim oSh As Shape 
Dim x As Long 
With oSl.Shapes 
For x = .Count To 1 Step -1 
    If .Item(x).Type = 23 Then 
     If ((.Item(x).Top >= "square.top") And (.Item(x).Left >= "square.left")) And (.Item(x).Top + .Item(x).Height <= "square.top" + "square.heigth") And (.Item(x).Left + .Item(x).Width <= "square.left" + square.width") Then 
     .Item(x).Delete 
     End If 
    End If 
Next 
End With 
End Sub 

「square.x」代表您爲您的廣場設置的特定座標。

相關問題