Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Replace with numbers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frantisek Horalek - 15 Mar 2005 12:59 GMT
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
Helmut Weber - 15 Mar 2005 13:23 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.