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 / Programming / October 2005

Tip: Looking for answers? Try searching our database.

select the word but not the space behind it

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ykchanaed - 17 Oct 2005 19:14 GMT
With Selection
.Moveend Unit:=wdWord, Count:=1
.movestart Unit:=wdWord, Count:=-1
.InsertBefore Text:="("
.InsertAfter Text:=")"
End With

I wrote the above to insert brackets to the word where the cursor locates.
But it included the space behind the word.
any way to improve it?
Tony Jollans - 17 Oct 2005 20:29 GMT
With Selection
.Expand Unit:=wdWord
.MoveEndWhile Cset:=" ", Count:=wdBackward
.InsertBefore Text:="("
.InsertAfter Text:=")"
End With

It's not perfect - put the cursor to the left or right of punctuation and it
will parenthesise the punctuation - but it would take more complex code to
trap that.
--
Enjoy,
Tony

> With Selection
> .Moveend Unit:=wdWord, Count:=1
[quoted text clipped - 6 lines]
> But it included the space behind the word.
> any way to improve it?
ykchanaed - 21 Oct 2005 15:56 GMT
Dear Tony,
This works fine with me.
Thanks a lot.

> With Selection
> ..Expand Unit:=wdWord
[quoted text clipped - 20 lines]
> > But it included the space behind the word.
> > any way to improve it?
 
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.