What I have:
Dim Char_Date, Char_DateTime, objFileSys, objFolder, objFile, objRead, objWrite, objRegEx, strFile, intLength, strEnd
Dim sContents, sDir, sFile, nFile, iMatch, colMatches, strFileName
Dim EDIDir, EDICount, EXT
EXT = "edi"
EDIDir = "C:\Users\Mike\Google Drive\- Projects\Test Scripts\HTA\TEST EDI FILES"
EDICount = 0
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileSys.GetFolder(EDIDir)
For Each objFile In objFolder.Files
If LCase((objFileSys.GetExtensionName(objFile))) = LCase(EXT) Then
EDICount = EDICount + 1
End If
Next
Msgbox "Detected EDI Files: " & EDICount
'# Error check EDI files.
Const ForAppending = 8
Const ForReading = 1
Const ForWriting = 2
For Each objFile In objFolder.Files
If LCase((objFileSys.GetExtensionName(objFile))) = LCase(EXT) Then
Set strFileName = objFileSys.GetFileName(objFile)
Set objFile = objFileSys.OpenTextFile(objFile)
sContents = objFile.ReadAll
objFile.Close
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.IgnoreCase = False
objRegEx.Global = True
objRegEx.Pattern = "19\*\*"
Set colMatches = objRegEx.Execute(sContents)
If colMatches.Count >= 1 Then
Msgbox colMatches.Count & " errors in " & strFileName & "."
Else
Msgbox "0 errors found in " & strFileName & "."
End If
End If
Next
Msgbox "Error checking complete."
The first part of the script runs just fine. It tells me how many EDI files I have in a specific directory. When it gets to the error checking, though, it doesn't work. From all the examples I have seen...it should. I keep getting an error that states: "Object required: '[string: MYFILENAME.EDI"]'
Any ideas?



Help
Back to top











