Hello everyone, as I'm new to this forum and can not seem to find a response which helps me in answering my question. I"ve created a VB Script (.vbs file) code per below to read a text file and write/modify any specific word from this text file to another word then save and close. I've tested in a small set of data (around 20 rows of records and the code works) but when I implemented to the actual text file which is around 400,000 KB, I receive the following error message.
![Name: errormessage.png
Views: 66
Size: 7.0 KB]()
Script: W:\Processing\Batch\HIRVABDetailCW.vbs
LIne: 9
Char: 1
Error: OUt of memory
Code: 800A0007
Source: Microsoft VBScript runtime error
Code:
Const ForReading = 1
Const ForWriting = 2
Const FileIn = "C:\Documents and Settings\NAME\AB_Current_Week.txt"
Const FileOut = "C:\Documents and Settings\NAME\AB_Current_Week.txt" '<== Change to prevent overwrite of original file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(FileIn, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "HIRV 13", "HIRV 14")
Set objFile = objFSO.OpenTextFile(FileOut, ForWriting)
objFile.WriteLine strNewText
objFile.Close
Any help you can provide will be much appreciated.
Thank you.
Script: W:\Processing\Batch\HIRVABDetailCW.vbs
LIne: 9
Char: 1
Error: OUt of memory
Code: 800A0007
Source: Microsoft VBScript runtime error
Code:
Const ForReading = 1
Const ForWriting = 2
Const FileIn = "C:\Documents and Settings\NAME\AB_Current_Week.txt"
Const FileOut = "C:\Documents and Settings\NAME\AB_Current_Week.txt" '<== Change to prevent overwrite of original file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(FileIn, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "HIRV 13", "HIRV 14")
Set objFile = objFSO.OpenTextFile(FileOut, ForWriting)
objFile.WriteLine strNewText
objFile.Close
Any help you can provide will be much appreciated.
Thank you.