batch file to ftp code not running - please help!

W

WhytheQ

Hello All,
I've got the following code.
If I run this code from a file, and aimed at a file saved locally on
my pc, then it works fine and the file gets saved to the ftp site.
If I try running the below from a network drive I get an error 5:
"Invalid procedure call or argument"

Why is the move to the network drive causing these problems?

Any help much appreciated,
Jason.



'========================================
Sub PublishFile()

Dim strDirectoryList As String
Dim lStr_Dir As String
Dim lInt_FreeFile01 As Integer
Dim lInt_FreeFile02 As Integer

On Error GoTo Err_Handler
lStr_Dir = "\\imsfileserve\blah$\blah\blah\blah Daily Extract"
lInt_FreeFile01 = FreeFile
lInt_FreeFile02 = FreeFile

'' ANW 07-Feb-2003 :
strDirectoryList = lStr_Dir & "\directory"

'' Delete completion file
If Dir(strDirectoryList & ".out") <> "" Then Kill
(strDirectoryList & ".out")

'' Create text file with FTP commands
Open strDirectoryList & ".txt" For Output As #lInt_FreeFile01
Print #lInt_FreeFile01, "open ftp.micro.com"
Print #lInt_FreeFile01, "nickt"
Print #lInt_FreeFile01, "$!tk***$!"
Print #lInt_FreeFile01, "text"
Print #lInt_FreeFile01, "send \\imsfileserve\blah$\blah\blah\blah
Daily Extract\blah_Daily_Extract.txt targetdir/
Quickfire_Daily_Extract.txt"
Print #lInt_FreeFile01, "bye"
Close #lInt_FreeFile01

'' Create Batch program
Open strDirectoryList & ".bat" For Output As #lInt_FreeFile02
Print #lInt_FreeFile02, "ftp -s:" & strDirectoryList & ".txt"

Print #lInt_FreeFile02, "Echo ""Complete"" > " & strDirectoryList
& ".out"
Close #lInt_FreeFile02

'' Invoke Directory List generator
Shell (strDirectoryList & ".bat"), vbHide '', vbMinimizedNoFocus
'Wait for completion
Do While Dir(strDirectoryList & ".out") = ""
DoEvents
Loop

Application.Wait (Now + TimeValue("0:00:03"))

'' Clean up files
If Dir(strDirectoryList & ".bat") <> "" Then Kill
(strDirectoryList & ".bat")
If Dir(strDirectoryList & ".out") <> "" Then Kill
(strDirectoryList & ".out")
If Dir(strDirectoryList & ".txt") <> "" Then Kill
(strDirectoryList & ".txt")

bye:

Exit Sub

Err_Handler:
MsgBox "Error : " & Err.Number & vbCrLf & "Description : " &
Err.Description, vbCritical
Resume bye

End Sub
'========================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top