1. Home
  2. Computing & Technology
  3. Visual Basic

VBA - The Word Working Partner - Part 1

By , About.com Guide

7 of 7

Add a Line of WordArt

WordArt Result

WordArt Result

Suppose, however, that you frequently need to simply add a line of WordArt to the current paragraph where the cursor is using the text in the current line as the source. If the size, font, and style are always the same, you can code a quick VBA program to do this at the click of a button:

~~~~~~~~~~~~~~~~~~~~~~~~~
Sub WordArt()
Dim myRange As Range
Dim myArtText As String
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
myArtText = Selection.Text
Set myRange = _
  ActiveDocument.Range(Start:=Selection.Start, _
  End:=Selection.End)
ActiveDocument.Shapes.AddTextEffect(msoTextEffect22, _
  myArtText, "Impact", 16#, msoFalse, _
  msoFalse, 0, 20, myRange).Select
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB 6
  5. Learn VBA
  6. VBA - The Word Working Partner - Part 1

©2009 About.com, a part of The New York Times Company.

All rights reserved.