有没有一种方法可以确定用户是否使用 PowerPoint VBA 选择了形状或 table?

Is there a way to determine if the user selected a shape or a table with PowerPoint VBA?

我正在尝试编写一个 PowerPoint 宏,无论用户选择的是 PowerPoint table 还是“经典”形状(文本框等),它的行为都会有所不同。

有没有办法用 VBA 中的条件检查这个?

我找到了使用错误处理的变通方法,但我想有一种正确的方法可以做到这一点。

感谢任何帮助 谢谢!

像这样:

Sub TableOrShape()
    If ActiveWindow.Selection.ShapeRange(1).HasTable Then
        MsgBox "It's a table!"
    ElseIf ActiveWindow.Selection.ShapeRange(1).HasTextFrame Then
        MsgBox "It's a text box!"
    End If
End Sub