FindAndReplace problem

I has the following code to find and replace the content of rich text:

		Set body = newdoc.GetFirstItem("Content")

		Set rtnav = body.CreateNavigator

		

		If rtnav.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH) Then

			count% = 0

			Do

				count% = count% + 1

			Loop While rtnav.FindNextElement

’ Else

’ newdoc.Form = “Cheque for Print”

’ Call newdoc.Save(True, True)

’ Exit Sub

		End If		

		

		Set rtrange = body.CreateRange

		

		

		

		

		

		n = 0			

		For k = count% To 1 Step -1

			If Not rtnav.FindNthElement(RTELEM_TYPE_TEXTPARAGRAPH, _

			k) Then

				

				Exit For

			End If

			Call rtrange.SetBegin(rtnav)

			

			For i=0 To Ubound(SearchList)

				searchString = SearchList(i)

				replaceString = ReplaceLetterFormatVariable(searchString,ReplaceList)

				

				Call rtrange.SetBegin(rtnav)

				While rtrange.FindAndReplace _

				(searchString, replaceString, RT_FIND_CASEINSENSITIVE)

					Set rtrange = body.CreateRange				

					Call rtnav.FindNthElement(RTELEM_TYPE_TEXTPARAGRAPH, k)						

					Call rtrange.SetBegin(rtnav)		

					'Call rtrange.SetStyle(rtpStyle)

					n = n + 1

				Wend				

				Set rtrange = body.CreateRange				

				Call rtnav.FindNthElement(RTELEM_TYPE_TEXTPARAGRAPH, k)						

				Call rtrange.SetBegin(rtnav)									

				'Call rtrange.SetStyle(rtpStyle)

			Next

		Next			

’ End If

		If n > 0 Then

			Call body.Compact

		End If

It works fine. If the content contains image, the image disappear after find and replace. How can I do?

Subject: RE: FindAndReplace problem

I’m not sure – that’s a lot of code. It might just require a strategically placed call to Update or creation of a new navigator at some point.

But I don’t understand why you don’t just use RT_REPL_ALL option as opposed to iterating through the paragraphs.

You used Refresh(True), right?