squirrelman
Programmer
All,
I am getting an error that I cannot figure out. I have a bit of code that loops through a folder and if it finds a file without a particular extension it goes onto the next file. Otherwise it does some processing of the file.
There are two such folders upon which this functionality is exercised. I am including the top part of each. The first succeeds without issue, but the second fails. I have added the failure message after the code. Both are laid out exactly the same way.
The good code:
.
.
.
filex = "txt"
ifcfolder = "D:\IFC\" & trim(Plant) & "\Outbound\Archive"
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists(ifcfolder) Then
Set iFolder = FSO.GetFolder(ifcfolder)
Else
Msgbox("Folder " & ifcfolder & " does not exist")
WScript.Quit
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("D:\IFC\" & trim(Plant) & "-Deliv.txt", True)
For Each f1 In fso.GetFolder(ifcfolder).Files
If InStr(f1.name, filex) = 0 Then
Continue
End If[
.
.
.
Bad code:
.
.
.
filex = "xml"
ifcfolder = "D:\IFC\" & trim(Plant) & "\Inbound\Archive"
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists(ifcfolder) Then
Set iFolder = FSO.GetFolder(ifcfolder)
Else
Msgbox("Folder " & ifcfolder & " does not exist")
WScript.Quit
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("D:\IFC\" & trim(Plant) & "Inv.txt", True)
For Each f2 In fso.GetFolder(ifcfolder).Files
If InStr(f2.name, filex) = 0 Then
Continue
End If
.
.
.
Error from bad code:
---------------------------
Windows Script Host
---------------------------
Script: D:\IFC\Load-Xref.vbs
Line: 79
Char: 4
Error: Type mismatch: 'Continue'
Code: 800A000D
Source: Microsoft VBScript runtime error
---------------------------
OK
---------------------------
Your help is greatly appreciated!
Regards,
David a.k.a. SquirrelMan
I am getting an error that I cannot figure out. I have a bit of code that loops through a folder and if it finds a file without a particular extension it goes onto the next file. Otherwise it does some processing of the file.
There are two such folders upon which this functionality is exercised. I am including the top part of each. The first succeeds without issue, but the second fails. I have added the failure message after the code. Both are laid out exactly the same way.
The good code:
.
.
.
filex = "txt"
ifcfolder = "D:\IFC\" & trim(Plant) & "\Outbound\Archive"
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists(ifcfolder) Then
Set iFolder = FSO.GetFolder(ifcfolder)
Else
Msgbox("Folder " & ifcfolder & " does not exist")
WScript.Quit
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("D:\IFC\" & trim(Plant) & "-Deliv.txt", True)
For Each f1 In fso.GetFolder(ifcfolder).Files
If InStr(f1.name, filex) = 0 Then
Continue
End If[
.
.
.
Bad code:
.
.
.
filex = "xml"
ifcfolder = "D:\IFC\" & trim(Plant) & "\Inbound\Archive"
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists(ifcfolder) Then
Set iFolder = FSO.GetFolder(ifcfolder)
Else
Msgbox("Folder " & ifcfolder & " does not exist")
WScript.Quit
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("D:\IFC\" & trim(Plant) & "Inv.txt", True)
For Each f2 In fso.GetFolder(ifcfolder).Files
If InStr(f2.name, filex) = 0 Then
Continue
End If
.
.
.
Error from bad code:
---------------------------
Windows Script Host
---------------------------
Script: D:\IFC\Load-Xref.vbs
Line: 79
Char: 4
Error: Type mismatch: 'Continue'
Code: 800A000D
Source: Microsoft VBScript runtime error
---------------------------
OK
---------------------------
Your help is greatly appreciated!
Regards,
David a.k.a. SquirrelMan