J
Jens-Erik
Hi
I have a problem with Find property in Word 2003. This works well
in Word 2000. The problem is when the last text is found and
replaced, then it start to go in a loop and insert the replaced
text over and over again on the same place.
The procedure (see example) search and replace (translate)
word/string repeatedly through the document. If Parameter 1 is
TRUE then text becomes bold. If Parameter 2 is TRUE then call
procedure DateRemove (Delete other text in the same paragraph)
Parameter 3 is text that will be replaced with Parameter 4. The
procedure is called from several points.
I hope someone can help me to make this Word 2003 compatible.
Thanks
Jens-Erik
Example:
....
Call RepeatedlySearch(True, False, "Postadresse: ", _
"Postal address: ")
....
Private Sub RepeatedlySearch(blnBoldText As Boolean, _
blnRemoveDate As Boolean, strSearchString As String, _
strReplaceText As String)
With Selection
.HomeKey Unit:=wdStory
..Find.Execute Findtext:=strSearchString, _
Forward:=True, Wrap:=wdFindStop
While .Find.Found = True
.Text = strReplaceText
If blnBoldText = True Then .Range.Bold = True
If blnRemoveDate = True Then
DateRemove
End If
Selection.MoveDown Unit:=wdLine, Extend:=wdMove
WordBasic.repeatFind
Wend
End With
End Sub ' RepeatedlySearch
----------------
I have a problem with Find property in Word 2003. This works well
in Word 2000. The problem is when the last text is found and
replaced, then it start to go in a loop and insert the replaced
text over and over again on the same place.
The procedure (see example) search and replace (translate)
word/string repeatedly through the document. If Parameter 1 is
TRUE then text becomes bold. If Parameter 2 is TRUE then call
procedure DateRemove (Delete other text in the same paragraph)
Parameter 3 is text that will be replaced with Parameter 4. The
procedure is called from several points.
I hope someone can help me to make this Word 2003 compatible.
Thanks
Jens-Erik
Example:
....
Call RepeatedlySearch(True, False, "Postadresse: ", _
"Postal address: ")
....
Private Sub RepeatedlySearch(blnBoldText As Boolean, _
blnRemoveDate As Boolean, strSearchString As String, _
strReplaceText As String)
With Selection
.HomeKey Unit:=wdStory
..Find.Execute Findtext:=strSearchString, _
Forward:=True, Wrap:=wdFindStop
While .Find.Found = True
.Text = strReplaceText
If blnBoldText = True Then .Range.Bold = True
If blnRemoveDate = True Then
DateRemove
End If
Selection.MoveDown Unit:=wdLine, Extend:=wdMove
WordBasic.repeatFind
Wend
End With
End Sub ' RepeatedlySearch
----------------