Visual Basic

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

VBA - The Word Working Partner - Part 1

By Dan Mabbutt, About.com

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

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Visual Basic

  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.