WordArt
A WordArt object is a special type of Shape object. WordArt is accessible from the Drawing toolbar. A WordArt sample is shown Figure B-12.
Figure B-12. Sample WordArt
To create a WordArt object, use the AddTextEffect method of the Shapes collection. The syntax is:
ShapesCollection
.AddTextEffect(PresetTextEffect, Text, _
FontName, FontSize, FontBold, FontItalic, Left, Top, _
Anchor
)
Most of these parameters are self-explanatory. The Anchor
parameter is the same as for the AddShapes method. The PresetTextEffect
parameter specifies the type of WordArt object and can be any of the MsoPresetTextEffect
constants msoTextEffect1
through msoTextEffect30
. The values of these constants correspond to the formats listed in the WordArt Gallery dialog box (numbered from left to right and from top to bottom).
The code in Example B-8 will display each of the 30 different WordArt text effects. It should be run on an empty document.
Example B-8. The ShowWordArtEffects Procedure
Sub ShowWordArtEffects() Dim sh As Shape Dim rng As Range Dim i As Integer Set rng = Selection.Range Set sh = ActiveDocument.Shapes.AddTextEffect(msoTextEffect1, _ "PresetTextEffect xx", "Arial", 24, False, False, _ 0, 0, rng) For i = msoTextEffect1 To msoTextEffect30 sh.TextEffect.PresetTextEffect = i sh.TextEffect.Text = "PresetTextEffect " & Format(i) sh.Visible = True Delay 1 Next i End Sub
Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.