-1

I need to know is selected shape word art or not.

Shape has property "Type" (returns enum MsoShapeType). When I insert word art and check this property - it returns msoAutoShape instead of msoTextEffect (with AutoShapeType==msoShapeRectangle).

How can I check that spae is word art (not usual rectangle with textbox) ?

Thanks!

4

1 回答 1

0

如果您选择整体 smartart 形状或单击 smartart 形状中的文本或选择 smartart 中的形状之一,ActiveWindow.Selection.ShapeRange(1) 将返回 smartart 形状。

所以

If ActiveWindow.Selection.ShapeRange(1).HasSmartArt Then
   Debug.Print "It's smart art"
End if

[编辑] 但正如你所指出的,这是针对 smartart,而不是文字艺术。我的错误,对不起。没有这样的艺术字形状;它更像是任何将艺术字格式应用于整个形状或形状中的文本的形状。这包括发光、反射、阴影等格式,或者可能是艺术字预设之一,这些不同效果的预选组合。我添加了一个示例,该示例将帮助识别形状中应用了这些预设的形状或文本范围。除了查看每次运行和每个可能应用的各种属性(发光、反射等)的文本框之外,我没有看到任何简单的方法来检查用户应用的艺术字格式。不幸的是,没有 WordArtFormat = None 告诉我们可以忽略它。它'

Sub WordArtist()

    Dim oSh As Shape
    Dim oRng As TextRange2

    ' Has word art formatting been applied to
    ' entire shape?
    Set oSh = ActiveWindow.Selection.ShapeRange(1)
    Debug.Print oSh.TextFrame2.WordArtFormat

    ' Has it been applied to individual chunks of
    ' text within the shape
    For Each oRng In oSh.TextFrame2.TextRange.Runs
        Debug.Print oRng.Font.WordArtFormat
    Next

    ' Note:
    ' A result of -2 for the entire shape could mean
    '   - No text in the shape; not really word art
    '   - Mixed formatting
    '   - Text/shape has had glow/shadow/reflection etc applied
    '     rather than one of the preset WordArt selections

End Sub
于 2014-01-28T21:13:23.890 回答