2017-07-25 55 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”代表您为您的广场设置的特定坐标。

相关问题