【问题标题】:Powerpoint Delete Shapes just on a part of a slidePowerpoint 仅在幻灯片的一部分上删除形状
【发布时间】:2017-12-30 22:29:17
【问题描述】:

我目前正在尝试使用宏删除幻灯片上的形状(用户绘制并在演示完成时保留的墨水形状)。它看起来像这样:

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

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

这可能吗,如果可以的话怎么办?

【问题讨论】:

  • 在删除项目之前,再添加几个测试。如果它的 .Top 和 .Left 等于或大于正方形的 .Top 和 .Left 并且如果它的 .Top + .Height 是 =
  • 效果很好!非常感谢!也许把它写成一个答案,所以我可以把它设置为最好的工作答案?
  • 很高兴它有所帮助,但更好的是,您为什么不发布可以作为答案的代码呢?这应该比我不详细的建议对更多人有用。

标签: vba ms-office powerpoint


【解决方案1】:

在史蒂夫的帮助下,我得到了它的工作。代码如下:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多