-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!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • check [this question and answer](http://stackoverflow.com/questions/16019942/find-the-type-of-a-shape). – Kazimierz Jawor Jan 28 '14 at 20:45
  • [This](http://stackoverflow.com/questions/16019942/find-the-type-of-a-shape) answer is not correct. expected result for Shape.Type property value is "msoTextEffect", actual result for word art shape is "msoAutoShape". That's the problem. So I have not ideas how to determinate that some shape is word art. – AntonKolesnikov Jan 29 '14 at 11:36
  • Re "What have you tried so far": I've tried to use some other properties to determinate that shape is word art but have not success - this shapes looks the same as rectangle shape + text box on it. Also I've tried to google any solution. And I've wrote about bug (that word art Shape.Type != msoTextEffect) on msdn site and didn't get feedback. – AntonKolesnikov Jan 29 '14 at 15:57
  • Could somebody please write, why peoples vote that this question is not useful or without research? Is it connected that I didn't find answer before post this question here and didn't provide some compleated solution for review here? Or it's connected only with my bad english? – AntonKolesnikov Jan 29 '14 at 16:08
  • People voted it as w/o research because your original question didn't make it clear that you HAD done some research on the problem. Your comments later make it clear that you have. By the way, msoTextEffect shape types are WordArt that was created in PPT 2003 and earlier. It all changed in 2007 and later. These later versions don't create msoTextEffect shapes and when you open an earlier presentation that includes them, they get converted to text boxes with various 3D and other formatting applied. – Steve Rindsberg Jan 29 '14 at 16:59

1 Answers1

0

If you select either the overall smartart shape or click into text within the smartart shape or select one of the shapes within the smart art, ActiveWindow.Selection.ShapeRange(1) will return the smartart shape.

So

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

[edited] But as you've pointed out, this is for smartart, not word art. My error, sorry. There isn't a WordArt shape as such; it's more like any shape that has had WordArt formatting applied to the shape as a whole or to text within the shape. That'd include formatting like glow, reflection, shadow and so on, or could be one of the WordArt presets, pre-selected combinations of these different effects. I've added an example that'll help identify shapes or ranges of text within shape that have these presets applied. I don't see any simple way of checking for user-applied WordArt formats other than looking at each run and each text box for each of the various properties (glow, reflection etc) that might be applied. Unfortunately, there's no WordArtFormat = None to tell us we can ignore it. It's either going to be one of the presets or -2, which can mean any of several things.

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
Steve Rindsberg
  • 14,442
  • 1
  • 29
  • 34