andysuth
07-18-2007, 01:07 AM
Hi,
Continuing on from previous thread, I'm trying to take a text file (.txt) and change one string from it (several times) to another and then save it as a new .txt file.
I'd thought I could use:
Dim vFF1 As Long, vNIStep As String, vPBody As String, vOIStep As String
versionint = 1002
vNIStep = "C:\Path\" & versionint & "_inteps.txt"
vOIStep = "C:\Path\inteps.txt"
vPBody = Replace(vOIStep, "1001", versionint)
vFF1 = FreeFile
Open vNIStep For Output As #vFF1
Print #vFF1, vPBody
Close #vFF1
But this only writes the path name in the text file (duh!),
I know the replace command works (because I wrote the text to be replaced at the end of the file path and it correctly replaced it twice), but not sure if I have to read the whole file in, and then run it as a string through the replace command.
It's only a short file (40 lines long/ about 50 Chr/lne), but I'm not even sure how to read the file in.
Any ideas?
Cheers,
-AS
Continuing on from previous thread, I'm trying to take a text file (.txt) and change one string from it (several times) to another and then save it as a new .txt file.
I'd thought I could use:
Dim vFF1 As Long, vNIStep As String, vPBody As String, vOIStep As String
versionint = 1002
vNIStep = "C:\Path\" & versionint & "_inteps.txt"
vOIStep = "C:\Path\inteps.txt"
vPBody = Replace(vOIStep, "1001", versionint)
vFF1 = FreeFile
Open vNIStep For Output As #vFF1
Print #vFF1, vPBody
Close #vFF1
But this only writes the path name in the text file (duh!),
I know the replace command works (because I wrote the text to be replaced at the end of the file path and it correctly replaced it twice), but not sure if I have to read the whole file in, and then run it as a string through the replace command.
It's only a short file (40 lines long/ about 50 Chr/lne), but I'm not even sure how to read the file in.
Any ideas?
Cheers,
-AS