Need a script which finds 1line and replace that 1line with 2lines in notepad using QTP

I have a code which finds and replace text in notepad.but i want to replace that text line with 2lines. 2lines is having different text .1st line is possible in my code,but after that i need one more line having text it should in in new line. here is my Code

 

 

 

 

 

 

Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Users\sd3116\Downloads\20\hhh.txt", ForReading)
strText = objFile.ReadAll
objFile.Close

strNewText = Replace(strText, " 108", " 109")

Set objFile = objFSO.OpenTextFile("C:\Users\sd3116\Downloads\20\hhh.txt", ForWriting)
objFile.WriteLine strNewText

objFile.Close

Msgbox "hi"

Parents Reply Children
  • Hi Mark,

     

    thanks for the response, i tried that already.its not working.but my issue is solved by passing a string,which contains 2lines with    & vbCrLf & in between,and passing that string into this Replace method. I tried and its working properly

     

    str = "Hello" &vbNewLine& "line2

    strNewText2 = Replace(strText, "108", str )