This questions is more of a "why doesn't this script work".
It used to work, but now I have no clue why. It is supposed to run on a specific computer, but it doesn't completely work. Then I took the script home to work on it, and it worked perfectly fine on my computer, so I am kind of lost as to why it wouldn't work on a specific computer.
Here is the line of code that is giving me trouble.
Then I have this very similar lines of codes that do work.
Any help would really be appreciated. I am pulling my hair out at this moment.
It used to work, but now I have no clue why. It is supposed to run on a specific computer, but it doesn't completely work. Then I took the script home to work on it, and it worked perfectly fine on my computer, so I am kind of lost as to why it wouldn't work on a specific computer.
Here is the line of code that is giving me trouble.
Code:
line=0
Set txtFile1 = objfso.OpenTextFile(objFileNameOld, ForReading)
Set strLine1 = CreateObject("VBScript.RegExp")
Do Until txtFile1.AtEndOfStream
line=line+1
'Set f = objfso.OpenTextFile(objFileNameOld, ForWriting)
strMatch = False
strLine1 = txtFile1.Readline
tempstrLine = strLine1
MyArray = Split(strLine1, ",", -1, 1)
strLine1 = MyArray(1)
Set txtFile2 = objfso.OpenTextFile(objFileName, ForReading)
Do Until txtFile2.AtEndOfStream
strLine2 = txtFile2.Readline
MyArray2 = Split(strLine2, ",", -1, 1)
strLine2 = MyArray2(1)
If Trim(UCase(strLine2)) = Trim(UCase(strLine1)) Then
strMatch = True
Else
End If
Loop
txtFile2.Close
If strMatch <> True then
'f.close
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False
objExcel.Workbooks.Add
Set objWorkbook = objExcel.Workbooks.Open (objFileNameOld)
objExcel.Cells(line, 1).Value = GetCustomDate
objExcel.Cells(line, 5).Value = "REMOVED"
objExcel.ActiveWorkBook.SaveAs objFileNameOld
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
End If
Loop
txtFile1.Close
txtFile2.Close
f.close
Then I have this very similar lines of codes that do work.
Code:
Dim txtFile, txtFile2, strLine2
Set txtFile1 = objfso.OpenTextFile(objFileName, ForReading)
Set strLine1 = CreateObject("VBScript.RegExp")
Do Until txtFile1.AtEndOfStream
Set f = objfso.OpenTextFile(objFileNameOld, ForAppending)
strMatch = False
strLine1 = txtFile1.Readline
tempstrLine = strLine1
MyArray = Split(strLine1, ",", -1, 1)
strLine1 = MyArray(1)
Set txtFile2 = objfso.OpenTextFile(objFileNameOld, ForReading)
Do Until txtFile2.AtEndOfStream
strLine2 = txtFile2.Readline
MyArray2 = Split(strLine2, ",", -1, 1)
strLine2 = MyArray2(1)
If Trim(UCase(strLine2)) = Trim(UCase(strLine1)) Then
strMatch = True
strLine1=MyArray(4)
strLine2=MyArray2(4)
If strLine2 <> strLine1 Then
strMatch=False
End If
Else
End If
strLine1=MyArray(1)
strLine2=MyArray2(1)
Loop
txtFile2.Close
If strMatch <> True then
f.writeline tempstrLine
f.close
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False
objExcel.Workbooks.Add
Set objWorkbook = objExcel.Workbooks.Open (objFileNameOld)
objExcel.Cells(intNewRow, 5).Value = "NEW"
objExcel.ActiveWorkBook.SaveAs objFileNameOld
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
intNewRow=intNewRow+1
End If
Loop
txtFile1.Close
txtFile2.Close
f.close
Any help would really be appreciated. I am pulling my hair out at this moment.