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
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
Frantisek Horalek - 21 Mar 2005 15:07 GMT
>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.