Extend selection until a space?

E

Ed

I'm using Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend.
Is there an easy way to extend the selection until it hits a space? Or do
you have to extend, check the selection to see if it has encountered a
space, if not then loop?

Ed
 
D

Dave Lett

Hi Ed

Have a look at the MoveEndUntil method. YOu might end up with something like the following

Selection.MoveEndUntil Cset:=" ", Count:=10

HTH
Dave
 
M

Mark Tangard

Ed,

No need to loop. You can use:

Selection.MoveEndUntil CSet:=" "

Note that this extends the selection through the character immediately
*before* the space. To include the space itself, you'll need to add

Selection.MoveEnd Unit:=wdCharacter, Count:=1
 
E

Ed

Perfect, Mark! Thank you.

Ed

Mark Tangard said:
Ed,

No need to loop. You can use:

Selection.MoveEndUntil CSet:=" "

Note that this extends the selection through the character immediately
*before* the space. To include the space itself, you'll need to add

Selection.MoveEnd Unit:=wdCharacter, Count:=1
 

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