Re: Define paragraph range

Or a more elaborate version:

Sub AddBrackets()
Dim myRange As Range
Dim myFont As Font

' If nothing is selected, select current word
If Selection.Type = wdSelectionIP Then
End If
Set myRange = Selection.Range.Duplicate

' remove trailing space if necessary
myRange.MoveEndWhile Cset:=" ", Count:=wdBackward

' braces should get all the font properties of the first character
Set myFont = myRange.Characters(1).Font.Duplicate

myRange.InsertBefore "("
myRange.InsertAfter ")"
myRange.Characters.First.Font = myFont
myRange.Characters.Last.Font = myFont

End Sub

-- select current word if nothing is selected,
-- does not loose any formatting in the selected text,
-- make sure the opening brace has the formatting of the first character,
-- make sure the closing brace has the same formatting as the opening brace,
-- remove trailing spaces (from Word's "smart word selection")


"Graham Mayor" <gmayor@xxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
How about

Sub AddBrackets()
Dim sText As String
sText = Selection
Selection.TypeText "(" & sText & ")"
End Sub

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site
Word MVP web site
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Angie M. wrote:

I need to create a macro that inserts a bracket at the start and end
of a portion of text. The user will select the text (it can be a few
characters or an entire page). Any help would be appreciated. I'm
on Word 03.

Thank you