How to delete first char(s) in a selection without collapsing the selection

J

John Svendsen

Hi All:
I'm using VBA in Word 2003 and I need to delete the first 3 characters in a
selection, but when I do this the selection collapses. I need to keep this
to do other things in it. (I've tried to set a range, but when deleting the
first character it also collapses.
Any ideas?
Thanks for your kind help and attention.
TIA, JS
 
T

Tony Jollans

How are you deleting the characters? There are many ways to do this, for
example:

Selection.Start = Selection.Start + 3
ActiveDocument.Range(Selection.Start - 3, Selection.Start).Delete
 
F

Fumei2 via OfficeKB.com

Or....you can simply replace the selection directly.

Sub ReplaceFirstThree()
Selection.Text = Right(Selection.Text, Len(Selection.Text) - 3)
End Sub

The quick brown fox jumps (selected of course!)

is replaced with:

quick brown fox jumps (note the space before "quick" as count is only 3
characters)



Tony said:
How are you deleting the characters? There are many ways to do this, for
example:

Selection.Start = Selection.Start + 3
ActiveDocument.Range(Selection.Start - 3, Selection.Start).Delete
Hi All:
I'm using VBA in Word 2003 and I need to delete the first 3 characters in
[quoted text clipped - 4 lines]
Thanks for your kind help and attention.
TIA, JS
 

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