Please help. I'm trying to change a data list in Word 2002 that has
the following format:

[Bank 112]
2=BrightPiano Natural!
4=Honky Tonk Regular
6=DX Modern Regular
7=Harpsichord Regular
9=Celesta Regular
108=Glocken Regular

Each of the numbers that are followed by an "=" needs to be replaced
by itself minus 1, so that the above list would become:

[Bank 112]
1=BrightPiano Natural!
3=Honky Tonk Regular
5=DX Modern Regular
6=Harpsichord Regular
8=Celesta Regular
107=Glocken Regular

These items were originally listed as 1-based, and need to be
transformed to a 0-based list. There are several banks of not
sequentially numbered entries. Is there a macro, vba, or search and
replace trick that will save me the labor of manually re-typing my
entire (very long) list?


Thank you for any help!

Re: Find a number and replace it with that number less one? by Tony

Tony
Sun Oct 30 13:09:26 CST 2005

I don't think you can do it directly with a Find and Replace but this code
should do it for you ...

Selection.HomeKey wdStory

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "<[0-9]{1,}="
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With

While Selection.Find.Execute
Selection.Text = Str(Val(Selection) - 1) & "="
Selection.Collapse wdCollapseEnd
Wend

--
Enjoy,
Tony


<Smokin> wrote in message news:5j0am1dch5fcg4rivkndljksrsnd8gmgot@4ax.com...
> Please help. I'm trying to change a data list in Word 2002 that has
> the following format:
>
> [Bank 112]
> 2=BrightPiano Natural!
> 4=Honky Tonk Regular
> 6=DX Modern Regular
> 7=Harpsichord Regular
> 9=Celesta Regular
> 108=Glocken Regular
>
> Each of the numbers that are followed by an "=" needs to be replaced
> by itself minus 1, so that the above list would become:
>
> [Bank 112]
> 1=BrightPiano Natural!
> 3=Honky Tonk Regular
> 5=DX Modern Regular
> 6=Harpsichord Regular
> 8=Celesta Regular
> 107=Glocken Regular
>
> These items were originally listed as 1-based, and need to be
> transformed to a 0-based list. There are several banks of not
> sequentially numbered entries. Is there a macro, vba, or search and
> replace trick that will save me the labor of manually re-typing my
> entire (very long) list?
>
>
> Thank you for any help!
>



Re: Find a number and replace it with that number less one? by Smokin

Smokin
Sun Oct 30 16:39:03 CST 2005

Thank you very much... that did the math just fine. It leaves a
single space at the begining of the line. (maybe for a +/- sign?) .
Is there a way to now truncate the line and get rid of that beginning
space? Then all wil be well.

Thanks for your help.

On Sun, 30 Oct 2005 19:09:26 -0000, "Tony Jollans" <No Mail> wrote:

>Selection.HomeKey wdStory
>
>Selection.Find.ClearFormatting
>Selection.Find.Replacement.ClearFormatting
>With Selection.Find
> .Text = "<[0-9]{1,}="
> .Replacement.Text = ""
> .Forward = True
> .Wrap = wdFindStop
> .Format = False
> .MatchCase = False
> .MatchWholeWord = False
> .MatchAllWordForms = False
> .MatchSoundsLike = False
> .MatchWildcards = True
>End With
>
>While Selection.Find.Execute
> Selection.Text = Str(Val(Selection) - 1) & "="
> Selection.Collapse wdCollapseEnd
>Wend


Re: Find a number and replace it with that number less one? by Helmut

Helmut
Sun Oct 30 16:41:14 CST 2005

Hi,

try CStr instead of Str.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Re: Find a number and replace it with that number less one? by Tony

Tony
Sun Oct 30 17:06:25 CST 2005

Sorry .. and thanks, Helmut!

--
Enjoy,
Tony


"Helmut Weber" <nbhymsjxdgcn@mailinator.com> wrote in message
news:quiam1ln6dumf04p9h7jemqaqon7jv41h4@4ax.com...
> Hi,
>
> try CStr instead of Str.
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"