Hello All,
I am trying to read a .RTF file and make changes to three lines.
Originally tried just writing to a variable with the changed lines, but the file is so large the computer will hang on this file for quite awhile. When it is reading the rest of the file, and that is before it has actually written the new file.
Decided to write it to an array and use replace to break out the new stuff.
Seemed like a good idea, I am wondering if I am running out of space in the array or my memory.
I am getting "Microsoft VBScript runtime error: Subscript out of range: 'i'", but first I get "The storage control block address is invalid".
Please find code below and many thanks to any assistance to this issue.
rnpIII
CoServ IT
I am trying to read a .RTF file and make changes to three lines.
Originally tried just writing to a variable with the changed lines, but the file is so large the computer will hang on this file for quite awhile. When it is reading the rest of the file, and that is before it has actually written the new file.
Decided to write it to an array and use replace to break out the new stuff.
Seemed like a good idea, I am wondering if I am running out of space in the array or my memory.
I am getting "Microsoft VBScript runtime error: Subscript out of range: 'i'", but first I get "The storage control block address is invalid".
Please find code below and many thanks to any assistance to this issue.
Code:
Sub GetSignatureFile
UName = "Test"
UPhone = "940-321-1234"
UTitle = "Someone who works here"
s = sline & vbCrLf
Set Folder = ofso.GetFolder(SourceDir)
For Each file In Folder.Files
If SignatureName &".rtf" = File.Name Then
Set ots = ofso.OpenTextFile (File, ForReading)
Do While Not ots.AtEndOfStream
sline = ots.readall
Loop
ots.close
RTFAr = Split (sline, vbCrLf)
For i = 0 to Ubound(RTFAr)
'WScript.Echo RTFAr(i)
If RTFAr(i) = RTFName Then
RTFAr(i) = Replace (RTFAr(i), "Name", UName)
ElseIf RTFAr(i) = RTFTitle Then
RTFAr(i) = Replace (RTFAr(i), "Job Title", UTitle)
ElseIf RTFAr(i) = RTFPhone Then
RTFAr(i) = Replace (RTFAr(i), "940-xxx-xxx", UPhone)
Exit For
End If
WScript.Echo RTFAr(i)
ReDim Preserve RTFAr(i)
Next
End If
Next
End Sub
rnpIII
CoServ IT