MoveStart of Range

G

Greg Maxey

Is there a method that I may be unaware of for moving the start of a
range to just *after* a certain character?

E.g., suppose my range is "SSN: 123-45-6789" and I want to redefine
the range to include only the numerals. I can use:

..MoveStartUntil Cset:=vbTab, Count:=wdForward
..MoveStart wdCharacter, 1


It would be nice if there was a .MoveStartUntil(and including) ... or
..MoveStartUntil + n characters.

Is there anything like that?

Thanks.
 
J

Jean-Guy Marcil

Greg Maxey was telling us:
Greg Maxey nous racontait que :
Is there a method that I may be unaware of for moving the start of a
range to just *after* a certain character?

E.g., suppose my range is "SSN: 123-45-6789" and I want to redefine
the range to include only the numerals. I can use:

.MoveStartUntil Cset:=vbTab, Count:=wdForward
.MoveStart wdCharacter, 1


It would be nice if there was a .MoveStartUntil(and including) ... or
.MoveStartUntil + n characters.

Is there anything like that?

Do you mean something like:

With rgeTest
Do While .Characters(1) Like "[!0-9]"
.MoveStart wdCharacter, 1
Loop
End With

or

n = 5
With rgeTest
For i = 1 To n
.MoveStart wdCharacter, 1
Next
End With

???


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

Greg Maxey

JGM

Not exactly. While your first example would work for the example
cited, I was looking for one line of code that would move a range just
past a designated character rather than up to and including that
charcter.

Say we have text strings like:

pName = "Name:<tab>Greg"
pDOB = "DOB:<tab>12/31/58"
pSSN = "SSN:<tab>123-45-5789"

myRng1.Text = pName
myRng2.Text = pDOB
myRng3.Text = pSSN

Now I want to move the range to include only "Greg" or "12/31/58" or
"123-45-6789"

Seems there should be a myRng1.MoveStartJustPassed vbTab, 1
or
myRng1.MoveStartUntil vbTab, 1 + 1 wdCharacter






to right of the
Jean-Guy Marcil said:
Greg Maxey was telling us:
Greg Maxey nous racontait que :
Is there a method that I may be unaware of for moving the start of a
range to just *after* a certain character?

E.g., suppose my range is "SSN: 123-45-6789" and I want to redefine
the range to include only the numerals. I can use:

.MoveStartUntil Cset:=vbTab, Count:=wdForward
.MoveStart wdCharacter, 1


It would be nice if there was a .MoveStartUntil(and including) ... or
.MoveStartUntil + n characters.

Is there anything like that?

Do you mean something like:

With rgeTest
Do While .Characters(1) Like "[!0-9]"
.MoveStart wdCharacter, 1
Loop
End With

or

n = 5
With rgeTest
For i = 1 To n
.MoveStart wdCharacter, 1
Next
End With

???


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
D

Doug Robbins - Word MVP

myrange.Start = myrange.Start + InStr(myrange, vbTab)

Returns Greg from the range pName = "Name:<tab>Greg

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Greg Maxey said:
JGM

Not exactly. While your first example would work for the example
cited, I was looking for one line of code that would move a range just
past a designated character rather than up to and including that
charcter.

Say we have text strings like:

pName = "Name:<tab>Greg"
pDOB = "DOB:<tab>12/31/58"
pSSN = "SSN:<tab>123-45-5789"

myRng1.Text = pName
myRng2.Text = pDOB
myRng3.Text = pSSN

Now I want to move the range to include only "Greg" or "12/31/58" or
"123-45-6789"

Seems there should be a myRng1.MoveStartJustPassed vbTab, 1
or
myRng1.MoveStartUntil vbTab, 1 + 1 wdCharacter






to right of the
Jean-Guy Marcil said:
Greg Maxey was telling us:
Greg Maxey nous racontait que :
Is there a method that I may be unaware of for moving the start of a
range to just *after* a certain character?

E.g., suppose my range is "SSN: 123-45-6789" and I want to redefine
the range to include only the numerals. I can use:

.MoveStartUntil Cset:=vbTab, Count:=wdForward
.MoveStart wdCharacter, 1


It would be nice if there was a .MoveStartUntil(and including) ... or
.MoveStartUntil + n characters.

Is there anything like that?

Do you mean something like:

With rgeTest
Do While .Characters(1) Like "[!0-9]"
.MoveStart wdCharacter, 1
Loop
End With

or

n = 5
With rgeTest
For i = 1 To n
.MoveStart wdCharacter, 1
Next
End With

???


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

Greg Maxey

Doug,

Yes that would do. Thanks.
myrange.Start = myrange.Start + InStr(myrange, vbTab)

Returns Greg from the range pName = "Name:<tab>Greg

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Greg Maxey said:
JGM

Not exactly. While your first example would work for the example
cited, I was looking for one line of code that would move a range just
past a designated character rather than up to and including that
charcter.

Say we have text strings like:

pName = "Name:<tab>Greg"
pDOB = "DOB:<tab>12/31/58"
pSSN = "SSN:<tab>123-45-5789"

myRng1.Text = pName
myRng2.Text = pDOB
myRng3.Text = pSSN

Now I want to move the range to include only "Greg" or "12/31/58" or
"123-45-6789"

Seems there should be a myRng1.MoveStartJustPassed vbTab, 1
or
myRng1.MoveStartUntil vbTab, 1 + 1 wdCharacter






to right of the
Jean-Guy Marcil said:
Greg Maxey was telling us:
Greg Maxey nous racontait que :

Is there a method that I may be unaware of for moving the start of a
range to just *after* a certain character?

E.g., suppose my range is "SSN: 123-45-6789" and I want to redefine
the range to include only the numerals. I can use:

.MoveStartUntil Cset:=vbTab, Count:=wdForward
.MoveStart wdCharacter, 1


It would be nice if there was a .MoveStartUntil(and including) ... or
.MoveStartUntil + n characters.

Is there anything like that?

Do you mean something like:

With rgeTest
Do While .Characters(1) Like "[!0-9]"
.MoveStart wdCharacter, 1
Loop
End With

or

n = 5
With rgeTest
For i = 1 To n
.MoveStart wdCharacter, 1
Next
End With

???


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

Helmut Weber

Hi Greg,

maybe something along these lines:

Dim rTmp As Range
Set rTmp = ActiveDocument.Range
With rTmp.Find
.Text = "123-45-6789"
If .Execute Then MsgBox rTmp
'otherwise rTmp is still the document's range
End With

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
K

Klaus Linke

And two more:
..MoveStartUntil CSet:="0123456789", Count:=wdForward
or .MoveStartWhile CSet:="SSN:" & vbTab, Count:=wdForward

Greetings,
Klaus
 

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