Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
sparks sparks is offline
external usenet poster
 
Posts: 1
Default Decided to put this question in a new message

I have to take a ton of variables and change the names..
Luck has it that they are formatted the same

Q9BOB
Q10Carl
Q11DOB
Q12RACE
..
..
..
Q149Pre

the thing is I have to rename them all and reduce the value by 2.
Q7BOB
Q8Carl
Q9DOB
Q10RACE
..
..
..
Q147Pre


Should I be looking for Numeric or chr substrings to identify what is
the number in the variable name that I have to subtract
is there a command in the mid statement to find the first chr after a
number or how should I go about parsing out the number making sure to
get the correct amount of numerics.

I assume it will always be mid(1, to take care of the Q but length of
the numerics.
Should I look for ascii values and find out when the next one is over
57 then I am at the end of the numeric sequence.

thank you from a very confused persion...I have all the tools but not
sure how to put it together

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Decided to put this question in a new message

Use a macro containing the following code:

Dim srange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="Q[0-9]{1,}", MatchWildcards:=True, _
MatchCase:=False, Wrap:=wdFindStop, Forward:=True) = True
Set srange = Selection.Range.Duplicate
Selection.Collapse wdCollapseEnd
Selection.MoveRight wdCharacter, 1
srange.Text = "Q" & (Mid(srange.Text, 2) - 2)
Loop
End With


--
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

"sparks" wrote in message
...
I have to take a ton of variables and change the names..
Luck has it that they are formatted the same

Q9BOB
Q10Carl
Q11DOB
Q12RACE
.
.
.
Q149Pre

the thing is I have to rename them all and reduce the value by 2.
Q7BOB
Q8Carl
Q9DOB
Q10RACE
.
.
.
Q147Pre


Should I be looking for Numeric or chr substrings to identify what is
the number in the variable name that I have to subtract
is there a command in the mid statement to find the first chr after a
number or how should I go about parsing out the number making sure to
get the correct amount of numerics.

I assume it will always be mid(1, to take care of the Q but length of
the numerics.
Should I look for ascii values and find out when the next one is over
57 then I am at the end of the numeric sequence.

thank you from a very confused persion...I have all the tools but not
sure how to put it together



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Mail Merge to Email to Multiple Recipients in the Same Mes Mark V Mailmerge 13 April 21st 23 05:06 PM
Features godmongo Microsoft Word Help 20 July 22nd 06 07:37 AM
Request for Help: Sending HTML Email, without any images embedded; details in message body BrownBullhead New Users 1 July 18th 06 03:37 PM
Strange spelling message New Users 12 July 9th 06 10:15 AM
Exam question wrong about Word? Opinions, please! Jamie Furlong New Users 6 April 18th 06 11:56 AM


All times are GMT +1. The time now is 09:27 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"