Hi,
Thanks for your response. Below is what I have tried doing.But it is not working. I'm very new to QTP. If you can help me correct it, it would be good.
The below code is not working. It is not replacing the word "QTP" with "Mercury". Opening the file for Writing (Set first_file = FS.GetFile(Doc1Path).OpenAsTextstream(ForWriting,0)) is clearing the worddoc. So I'm stuck.
***********************************************************************************
***********************************************************************************
Thanks for your response. Below is what I have tried doing.But it is not working. I'm very new to QTP. If you can help me correct it, it would be good.
The below code is not working. It is not replacing the word "QTP" with "Mercury". Opening the file for Writing (Set first_file = FS.GetFile(Doc1Path).OpenAsTextstream(ForWriting,0)) is clearing the worddoc. So I'm stuck.
***********************************************************************************
Code:
Dim Doc1Path
const ForReading = 1
Doc1Path = "D:\QTP Practice\QTP.docx"
Public Function ReplaceWord(Doc1Path)
Set FS = CreateObject("Scripting.FileSystemObject")
Set first_file = FS.GetFile(Doc1Path).OpenAsTextstream(ForReading,0)
Do while first_file.AtEndOfStream =False
str1=first_file.Read(1000)
Replace str1,"QTP","Mercury"
Loop
first_file.Close()
End Function
ReplaceWord(Doc1Path)