Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Long Documents / September 2004

Tip: Looking for answers? Try searching our database.

Put parenthesis around selected text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joao Barros - 12 Sep 2004 23:50 GMT
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
Greg Maxey - 13 Sep 2004 00:12 GMT
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

Signature

Greg Maxey
A peer in "peer to peer" support
Rockledge, FL
To e-mail, edit out the "w...spam" in gmaxey@whamspammvps.org

> Hi,
>
[quoted text clipped - 6 lines]
>
> Joao
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.