klewis10367
MIS
I have the following code running as an ActiveX Script using DTS. The problem that I run into is that sometimes the file exists but has no data. Therefore a size of 0. When I run the code it comes back as "Object Required:sFilename" error on line 11. However if I remove the size condition the code runs fine. I am using the result to determine my next task.
Function Main()
Dim oFSO, sFileName
' Get the name of the file from the Connection "Text File (Source)"
sFilename = DTSGlobalVariables.Parent.Connections("GDM RDP").DataSource
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Check for file and return appropriate result
If oFSO.FileExists(sFilename) Then
If sFilename.size >0 Then
Main = DTSTaskExecResult_Success
Else
Main = DTSTaskExecResult_Failure
End If
Else
Main = DTSTaskExecResult_Failure
End If
Set oFSO = Nothing
End Function
Function Main()
Dim oFSO, sFileName
' Get the name of the file from the Connection "Text File (Source)"
sFilename = DTSGlobalVariables.Parent.Connections("GDM RDP").DataSource
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Check for file and return appropriate result
If oFSO.FileExists(sFilename) Then
If sFilename.size >0 Then
Main = DTSTaskExecResult_Success
Else
Main = DTSTaskExecResult_Failure
End If
Else
Main = DTSTaskExecResult_Failure
End If
Set oFSO = Nothing
End Function