Put parenthesis around selected text

J

Joao Barros

Hi,

Starting from a selected text, I would like to know how can I
automatically (shortcuts or macros) insert it between parenthesis. For
example, I have the text "abcdef ghij klm". I select "def gh" and want
to get ""abc(def gh)ij klm".

Thanks for your attention.

Joao
 
G

Greg Maxey

Joao,

Try:

Sub ParenSelection()

If Selection.End - Selection.Start = 0 Then Exit Sub
Selection.InsertBefore Chr$(40)
If Selection.Characters.Last.Text = " " Then _
Selection.MoveEnd wdCharacter, -1
Selection.InsertAfter Chr$(41)
Selection.Collapse wdCollapseEnd

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top