Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default batch file to ftp code not running - please help!

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
'========================================
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a Batch file from VBA D.riggins Excel Programming 6 September 1st 09 08:54 PM
Want to run a DOS batch file (.bat) From Excel VBA code Cazayoux Excel Programming 1 July 31st 06 10:45 PM
running a batch file Mohan[_2_] Excel Programming 3 April 10th 04 10:48 PM
Running a batch file from VB Graham Carter Excel Programming 3 August 29th 03 04:18 PM
Running a batch file from Excel VBA verizon Excel Programming 1 July 20th 03 09:27 AM


All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"