I've got working code (thanks to help from this forum) that will write to a file the first 42 characters of each line in numerous files. Works like a charm. However, I now have a need to also write characters from 10 other areas of each line.
For instance, in the code below, i need to modify GetContents like so:
From:
GetContents = Left(objReadFile.ReadLine,42)
To:
GetContents = Left(objReadFile.ReadLine,42) & "|" & Mid(objReadFile.ReadLine,893,6) & "|" '& Mid(objReadFile.ReadLine,900,6) & "|" & Mid(objReadFile.ReadLine,907,6) & "|" & Mid(objReadFile.ReadLine,914,6) & "|" & Mid(objReadFile.ReadLine,921,6) & "|" & Mid(objReadFile.ReadLine,928,6) & "|" & Mid(objReadFile.ReadLine,935,6) & "|" & Mid(objReadFile.ReadLine,942,6) & "|" & Mid(objReadFile.ReadLine,949,6) & "|" & Mid(objReadFile.ReadLine,956,6)
Or create a new variable (in addition to GetContents) for each Mid and then include pipe delimiting in the WriteLine.
However, in both cases, I'm receiving an error, "Input past end of file", which I suspect is due to the fact that not every line in the file has characters in those Mid points. Is there a way to code around that so I can just capture the empty character space?
For instance, in the code below, i need to modify GetContents like so:
From:
GetContents = Left(objReadFile.ReadLine,42)
To:
GetContents = Left(objReadFile.ReadLine,42) & "|" & Mid(objReadFile.ReadLine,893,6) & "|" '& Mid(objReadFile.ReadLine,900,6) & "|" & Mid(objReadFile.ReadLine,907,6) & "|" & Mid(objReadFile.ReadLine,914,6) & "|" & Mid(objReadFile.ReadLine,921,6) & "|" & Mid(objReadFile.ReadLine,928,6) & "|" & Mid(objReadFile.ReadLine,935,6) & "|" & Mid(objReadFile.ReadLine,942,6) & "|" & Mid(objReadFile.ReadLine,949,6) & "|" & Mid(objReadFile.ReadLine,956,6)
Or create a new variable (in addition to GetContents) for each Mid and then include pipe delimiting in the WriteLine.
However, in both cases, I'm receiving an error, "Input past end of file", which I suspect is due to the fact that not every line in the file has characters in those Mid points. Is there a way to code around that so I can just capture the empty character space?
Code:
If fso.FolderExists(Path_11101) Then
Set Folder = fso.GetFolder(Path_11101)
For Each File In Folder.files
If (inStr(File.Name, "14OP")) Then
'msgbox "Other\" & strDate & "-Download"
Set objReadFile = FSO.OpenTextFile(File,ForReading)
Do until objReadFile.AtEndofStream
GetContents = Left(objReadFile.ReadLine,42)
Set objTextFile = FSO.OpenTextFile(LogPath & "Search_Saig_Folders_ISIR_All_Heald_" & Year(Date) & Right("0" & Month(Date),2) & Right("0" & Day(Date),2) & ".txt", 8, True)
'objTextFile.Writeline FSO.GetFolder(Folder) & "\" & strDate & "-Download" & "|" & FSO.GetFileName(File.Name)
objTextFile.Writeline "11101-" & GetContents
Set objTextFile = nothing
Loop
End If
Next
End If