Hello.

I need to find the text "Number: xxx" and replace it with Ascending
numbers, starting at one given number, all this in the whole document.

I know that I can ask like this:
Start = CDbl(InputBox("What is the starting number?"))

But then I do not know how to loop this (until the end of the
document), although I was looking through these news.
And how to replace with my variable? I do not know how to specify the
expression.

Thank you very much for help

Imagino

Re: Replace with numbers by Helmut

Helmut
Tue Mar 15 06:23:09 CST 2005

Hi Frantisek, alias Imagino,

like this, in principle.
Above all, the example is restricted to the format ###.
Nothing for end users in a professional
environment, but maybe sufficient for a developer,
to reduce typing errors.

Sub test2()
Dim l As Variant
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
start:
l = InputBox("Start at: format ###")
If Not l Like "###" Then
GoTo start
End If
With rDcm.Find
.Text = "Number: xxx"
While .Execute
rDcm.Text = "Number: " & Format(l, "000")
l = l + 1
rDcm.Collapse direction:=wdCollapseEnd
Wend
End With

End Sub



Re: Replace with numbers by Frantisek

Frantisek
Mon Mar 21 08:07:36 CST 2005

>like this, in principle.
>Above all, the example is restricted to the format ###.
>Nothing for end users in a professional
>environment, but maybe sufficient for a developer,
>to reduce typing errors.

Great! Thank you very much, that's it"
I made some fixes and it serves as I wanted.