Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sequential ActiveX Scripts....

Status
Not open for further replies.

dswitzer

Technical User
Aug 2, 2002
298
US
I have 2 activex scripts:
1. Change input file name to filename with yesterday's date
2. Check to see if that file exists (if it doesn't, I delay for some time and loop it back to check)...

Both scripts run independently, but have issues running sequentially -- no errors, just ignores second script.
I'm guessing it has something to do with variable declaration or something but I am struggling identifying the issue.

Thoughts?


<CODE>
Option Explicit

Function Change()
Dim oConn, sFilename

' Filename format - rt_daily_20031013
sFilename = &quot;\\nfstmp\sas_share\switzerd\rt_daily_&quot; &Year(Now())
If Month(Now()) < 10 Then sFilename = sFilename & &quot;0&quot; & _
Month(Now()) Else sFilename = sFilename & Month(Now())
If Day(Now()) < 10 Then sFilename = sFilename & _
&quot;0&quot; & Day(Now()) Else sFilename = sFilename & Day(Now())-3

sFilename = DTSGlobalVariables(&quot;\\nfstmp\sas_share\switzerd\&quot;).Value & _
sFilename & &quot;.csv&quot;
'\\nfstmp\sas_share\switzerd' Set oConn = DTSGlobalVariables.Parent.Connections(&quot;Text File (Source)&quot;)
Set oConn = DTSGlobalVariables.Parent.Connections(&quot;Connection 1&quot;)
oConn.DataSource = sFilename

'Set oConn = Nothing

Change = DTSTaskExecResult_Success
msgbox &quot;Done Step1&quot;
End Function

'****************************************
'****************************************
'****************************************
'******* SECOND ACTIVEX SCRIPT BEGINS ***
'****************************************


Option Explicit

Function Check()
msgbox &quot;reached step2&quot;
Dim oFSO, oConn, sFileName, oFile

' Get the filename from my Text File connection called &quot;Text File (Source)&quot;
Set oConn = DTSGlobalVariables.Parent.Connections(&quot;Connection 1&quot;)
sFilename = oConn.DataSource


Set oConn = Nothing

Set oFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)


' Check File Exists first
If Not oFSO.FileExists(sFilename) Then
' Return Error
Check = DTSTaskExecResult_Failure
Else
' Get file object
Check = DTSTaskExecResult_Success
Set oFile = oFSO.GetFile(sFilename)
End If

Set oFile = Nothing
Set oFSO = Nothing

End Function

</CODE>





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top