PDA

View Full Version : Solved: Find and Replace in a Print Image (Text) File



jasoncw
01-24-2008, 07:19 AM
Hi, everyone. I am having an odd issue, and I hope there is a simple solution for it.

I am executing a simple find and replace procedure in a text file (print image file, *.prn), but the replacement is not showing in the document. I am simply trying to insert 6 carriage returns before a text string. The 6 carriage returns are not showing on the document, but I need to key over 6 times to get to the above line, so I know they are actually in the document. Any ideas? Here is my code:
Sub CWF_Print_Format()
Dim Rng As Range, sFind As String, sReplace As String
With ActiveDocument
Set Rng = .Range(5, .Range.End)
End With
sFind = " HMR2"
sReplace = Chr(13) & Chr(13) & Chr(13) & _
Chr(13) & Chr(13) & Chr(13) & sFind
With Rng.Find
.ClearFormatting
.Text = sFind
With .Replacement
.ClearFormatting
.Text = sReplace
End With
.Execute Replace:=wdReplaceAll
End With
End Sub
TIA for any input.

Jason

jasoncw
01-24-2008, 10:24 AM
Well, I figured a work-around. Rather than using Chr(13), I used vbCrLf, and it worked. :)