O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Sample WordArt

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required