![]() |
Replace a string in a word document with another string - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Replace a string in a word document with another string (/Thread-Replace-a-string-in-a-word-document-with-another-string) |
Replace a string in a word document with another string - rekha.naik - 09-19-2010 Hi, I am a beginner to QTP. I'm trying to write a script for replacing the word "QTP" with "Mercury" in a word document in location "D:\QTP Practice" in my local machine. The word document "QTP.doc" has the following data in it. ******************************************************* For testing QuickTest pro for searching a QTP word in the word document QTP .Searching for a word QTP from QTP, QTP . Test again for the word QTP . ******************************************************* I tried various methods of searching for the word and replacing it. Looks like I'm missing out on some important point. Kindly help me with the script. Thanks RE: Replace a string in a word document with another string - venkatbatchu - 09-19-2010 Hi Rekha, Please use Replace Function... Replace("Expression","Find","Replacement") Please let me know for further clarrification... Regards, Venkat.Batchu RE: Replace a string in a word document with another string - rekha.naik - 09-19-2010 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. *********************************************************************************** Code: Dim Doc1Path RE: Replace a string in a word document with another string - Saket - 09-22-2010 use word object model instead using Filesystemobject for handling a docx file. RE: Replace a string in a word document with another string - rekha.naik - 09-30-2010 I tried below pasted code and it did not replace the string. ********************************************************************* Code: strsearch = "QTP" RE: Replace a string in a word document with another string - cdesserich - 10-01-2010 This should work better, and you weren't calling save: Quote:Set obj_word = CreateObject("Word.Application") RE: Replace a string in a word document with another string - rekha.naik - 10-05-2010 Thank you. This worked ![]() RE: Replace a string in a word document with another string - manjunathb - 11-14-2013 Hi experts, I want to replace <system name>from an URL, how can i do this. http://<system name>:8080/<suffix> Here i need to replace <system name> with some IP address <10.127.0.0> my new link should look like http://10.127.0.0:8080/<suffix> Thanks and Regards, Manju RE: Replace a string in a word document with another string - pranikgarg - 11-14-2013 Hi Manjunathb, See there are lot of processes to solve your query. I am giving you simplest method to do this: Dim URL : URL = "http://<system name>:8080/<suffix> Dim RplString : RplString = "10.127.0.0" Msgbox Replace(URL, "<system name>", RplString) Check this. |