VBA 取消组合形状(SmartArt)

mic*_*24B 5 powerpoint vba

有谁知道如何通过 VBA 取消组合 SmartArt 元素?

Sub UngroupSmartArt()

Dim shapeWithSmartArt As Shape
Set shapeWithSmartArt = ActivePresentation.Slides(2).Shapes(2)

shapeWithSmartArt.Ungroup

End Sub
Run Code Online (Sandbox Code Playgroud)

我收到此代码的错误: “此成员只能为组访问。”

这对我来说没有任何意义,因为在 powerpoint 本身中很容易做到这一点(右键单击 SmartArt -> Group -> Ungroup)。这让我发疯:)

任何人都可以帮助我取消 SmartArt 元素/形状的分组吗?

我还查看了类似的问题,但它无法正常工作,因为与通过 powerpoint 本身制作的结果相比,未分组的结果是不同的。

请帮帮我。我真的很感激任何帮助!

mic*_*24B 4

通过VB代码根本不可能做到这一点。这也是微软的声明。使用 SmartArt 的缺点还在于用户无法使用宏(使用 Excel)记录在此类对象/元素上执行的任何操作。

也不可能通过VB更改SmartArt节点的宽度或高度属性,这实际上是我想将SmartArt元素更改为形状的原因,因为您可以通过代码轻松更改形状的宽度和高度属性。

微软和他们的开发人员确实应该考虑让 SmarArt 元素对开发人员更加友好,因为我注意到我并不是唯一一个遇到这些问题的人。

编辑:找到解决方案!有一种方法可以从 powerpoint 功能区执行命令。您需要首先选择形状,然后使用以下操作执行CommandBars.ExecuteMso : SmartArtConvertToShapes

Sub UngroupSmartArt()

Dim shapeWithSmartArt As Shape
Set shapeWithSmartArt = ActivePresentation.Slides(2).Shapes(2)

shapeWithSmartArt.Select
CommandBars.ExecuteMso("SmartArtConvertToShapes")

End Sub
Run Code Online (Sandbox Code Playgroud)

这仍然没有改变事实和我的观点:微软真的应该考虑让SmartArt元素对开发者更加友好!