在 Microsoft Word 中手动创建(即通过 GUI)的 SmartArt 对象不会显示在 ActiveDocument.Shapes 集合中。 IE。如果我从一个空白文档开始,然后手动创建一个包含一些内容的 SmartArt,然后调用 ActiveDocument.Shapes.Count - 它返回 0。
但是,如果我像这样使用 VBA 创建 SmartArt,那么它会显示在 ActiveDocument.Shapes 集合中。
Dim myShape As shape
Dim mySmartArt As SmartArt
Set myShape = ActiveDocument.Shapes.AddSmartArt(Application.SmartArtLayouts(1), 100, 100, 400, 400)
Set mySmartArt = myShape.SmartArt
到目前为止,我还没有找到任何资源可以指导我通过 VBA 访问 Word 中的 SmartArt 形状。
我尝试使用“记录宏”功能来生成它在手动创建 SmartArt 时运行的 VBA,但是,这只是返回一个空白宏。
任何见解将不胜感激!
通过功能区插入后,您可以通过
InlineShapes
收藏访问智能艺术
您可以将它们“迁移”到像这样的“正常”形状,然后按您期望的方式访问它们。
Sub convertInlineSmartArtToShape()
Dim iShp As InlineShape
For Each iShp In ThisDocument.InlineShapes
If iShp.HasSmartArt Then
iShp.ConvertToShape
End If
Next
End Sub