Find& replace one by one 
Author Message
 Find& replace one by one

Hi all, I am trying to do find and replace one by one. For
instance, find each 'shall' and add incremental integer
value after 'shall'. Please help a newbie!
Thx Paul


Mon, 10 Oct 2005 20:40:35 GMT  
 Find& replace one by one
Hi Paul

Check out the following link:

http://www.mvps.org/word/FAQs/Userforms/index.html

Look at the section: "Working with strings, dates and Find & Replace".

I hope this helps + Cheers - Peter



Quote:
> Hi all, I am trying to do find and replace one by one. For
> instance, find each 'shall' and add incremental integer
> value after 'shall'. Please help a newbie!
> Thx Paul



Mon, 10 Oct 2005 21:35:56 GMT  
 Find& replace one by one
Hi Paul,

Here is one way to do it:

Sub foo()
Dim oRange As Range
Dim i As Integer
Set oRange = ActiveDocument.Range
i = 1
'take care of the initial one found
With oRange.Find
        .ClearFormatting
        .Forward = True
        .Text = [your text]
        .Replacement.Text = oRange.Text & i
        .Execute
End With
' loop through the rest
 Do While oRange.Find.Found
 'increment your integer value
     i = i + 1
     Set oRange = odoc.Range(oRange.End + 1, ActiveDocument.Range.End)
     With oRange.Find
         .ClearFormatting
         .Forward = True
         .Text = [your text]
         .Replacement.Text = oRange.Text & i
         .Execute
     End With
 Loop
Set oRange = Nothing
End Sub

HTH and have a great day.

Steve


Quote:
> Hi all, I am trying to do find and replace one by one. For
> instance, find each 'shall' and add incremental integer
> value after 'shall'. Please help a newbie!
> Thx Paul



Mon, 10 Oct 2005 21:44:22 GMT  
 Find& replace one by one
Thx folks!
Quote:
>-----Original Message-----
>Hi Paul

>Check out the following link:

>http://www.mvps.org/word/FAQs/Userforms/index.html

>Look at the section: "Working with strings, dates and
Find & Replace".

>I hope this helps + Cheers - Peter




Quote:

>> Hi all, I am trying to do find and replace one by one.
For
>> instance, find each 'shall' and add incremental integer
>> value after 'shall'. Please help a newbie!
>> Thx Paul

>.



Mon, 10 Oct 2005 21:58:54 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Find and Replace one by one

2. Would it be one big find and replace

3. -VB one-one-one tutoring

4. Global replace one string with another

5. Replace one contact category with another

6. Replacing all paragraph marks in a certain style EXCEPT the last one in this style

7. Replace two paragraph signs with one

8. Replacing one field with another field

9. Replace one Character by 3 in a string

10. how to replace more than one string

11. Replacing Standart Windows Scrollbar with a graphical-one (made by my own)

12. Replace the value of one fields in a Table

 

 
Powered by phpBB® Forum Software