我需要知道是否选择了形状艺术字。
Shape具有属性“Type”(返回枚举MsoShapeType)。 当我插入艺术字并检查此属性时 - 它返回msoAutoShape而不是msoTextEffect(使用AutoShapeType == msoShapeRectangle)。
如何检查spae是否为文字艺术(通常不带文本框的矩形)?
谢谢!
答案 0 :(得分:0)
如果您选择整体智能形状或单击智能形状中的文本或选择智能艺术中的其中一个形状,ActiveWindow.Selection.ShapeRange(1)将返回智能形状。
所以
If ActiveWindow.Selection.ShapeRange(1).HasSmartArt Then
Debug.Print "It's smart art"
End if
[编辑] 但正如你所指出的,这是为了smartart,而不是艺术。我的错误,抱歉。 没有艺术字形状;它更像任何将艺术字格式应用于整个形状或形状内的文本的形状。这包括像发光,反射,阴影等格式,或者可以是艺术字预设之一,预先选择这些不同效果的组合。我添加了一个示例,它有助于识别应用了这些预设的形状内的文本形状或范围。我没有看到任何简单的方法来检查用户应用的艺术字格式,除了查看每个运行和每个可能应用的各种属性(发光,反射等)的文本框。不幸的是,没有WordArtFormat =无告诉我们我们可以忽略它。它要么是预设之一,要么是-2,这可能意味着任何一些事情。
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