Powerpoint删除仅在幻灯片的一部分上形状

时间:2017-07-25 06:45:55

标签: vba ms-office 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

现在我只想让宏删除演示文稿的一部分上的墨迹形状,例如幻灯片上的特定方块。

这是可能的,如果是这样的话?

1 个答案:

答案 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”代表您为方块设置的特定坐标。