11-10-2008, 10:10 PM
I want to replace text from file2 with text copied from file1 using QTP. Can anyone help me find my way?
|
Copy text from file1, Replace text from file2 with text from file1
|
|
11-10-2008, 10:10 PM
I want to replace text from file2 with text copied from file1 using QTP. Can anyone help me find my way?
hi, bjotorres
Here simple code that I wrote. Code: 'path to file from which text will be copied
fromPath = "c:\from.txt"
'path to file where text should be replaced
toPath = "c:\to.txt"
textThatShouldBeReplaced = "some text to search"
'create File System Object to perform manipulations with files
Set fso = CreateObject("Scripting.FileSystemObject")
'Open text file for reading, copy text from it and close it
Set from_file = fso.OpenTextFile(fromPath, 1)
copiedText = from_file.ReadAll
from_file.Close
'Open text file for writing, replace text in it and close it
Set to_file = fso.OpenTextFile(toPath, 1)
fileText = to_file.ReadAll
to_file.Close
fileText = Replace(fileText, textThatShouldBeReplaced, copiedText, 1, -1, 1)
Set to_file = fso.OpenTextFile(toPath, 2)
to_file.Write fileText
to_file.Close |
|
« Next Oldest | Next Newest »
|
| Possibly Related Threads… | |||||
| Thread | Author | Replies | Views | Last Post | |
| Capture All text from webpage and copy it... | mpatra | 3 | 6,019 |
07-25-2018, 05:33 PM Last Post: vimlesh |
|
| LearnQuickTestPDF -does not work on just getting the text | jloyzaga | 0 | 1,753 |
02-10-2017, 10:59 AM Last Post: jloyzaga |
|
| How to edit a text in aParagraph | shaan.mishra87@gmail.com | 2 | 3,159 |
08-26-2016, 04:48 PM Last Post: shaan.mishra87@gmail.com |
|
| Copy folders from ALM | squadri | 0 | 2,211 |
08-16-2016, 06:23 PM Last Post: squadri |
|
| How to Verify Static Object Text which is changing Dynamically with Expected Result | johnny77 | 0 | 3,684 |
06-25-2015, 11:32 AM Last Post: johnny77 |
|