FTP via Access 2000 VBA shell

I would like to import multiple files into a specific directory via ftp by executing an ftp script file inside VBA code.  

So I created a script file named A2006D.TXT:

PROMPT
OPEN {addres}
{user}
{password}
QUOTE SITE FILETYPE=JES
lcd W:\PerformanceMeasures\Monthly Reports
MGET S200602*.mdb
BYE

Then I created a batch file named A2006E.BAT:

cd W:\PerformanceMeasures\Monthly Reports
ftp -s:A2006E.TXT


If I run A2006E.BAT from command line, it executes fine.

But if I run it through shell, it fails.
                Dim cmdline As String
                cmdline = CurrentProject.Path & "\A2006E.BAT"
                Shell cmdline, vbMaximizedFocus

What is wrong with my code? Can you help me?

Thank you,






ornekmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

thenelsonCommented:
A batch file run in shell needs to have quotation marks around it:
                cmdline = "" & CurrentProject.Path & "\A2006E.BAT"""
0
thenelsonCommented:
You would also need the qoutation marks if CurrentProject.Path has spaces in it.
0
ornekmAuthor Commented:
I tried both of your suggestions.  Still nothing.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

thenelsonCommented:
Put a code break on
              Shell cmdline, vbMaximizedFocus
put
?cmdline
in the immediate pane.  It should show
"<thePath>\A2006E.BAT"

You can also try
                cmdline = Chr(34) & CurrentProject.Path & "\A2006E.BAT" & Chr(34)

0
Gustav BrockCIOCommented:
You probably miss the command processor:

Public Sub RunFTP(ByVal strScriptFile As String)

' Usage Example:
'   call RunFTP("C:\temp\test.scr")
'
' Sample SCR File for NT/Win95 FTP
'   open someftpserver.com
'   anonymous
'   myaccount@myrealbox.com
'   lcd "c:\temp"
'   cd public
'   binary
'   prompt
'   mput *.jpg
'   get myfile.txt lastfile.txt
'   close
'   bye

  Dim strWinSysDir  As String
  Dim strQuote      As String
  Dim strMsgTitle   As String
  Dim strMsgPrompt  As String
  Dim lngMsgStyle   As Long
 
  strQuote = Chr(34)
  strMsgTitle = "FTP Transfer"
 
  If Len(strScriptFile) = 0 Then
    strMsgPrompt = "No script file specified." & vbCrLf & "Transfer cancelled."
    lngMsgStyle = vbCritical + vbOKOnly
    DoCmd.Beep
  Else
    If Len(Dir(strScriptFile)) = 0 Then
      strMsgPrompt = "Script file '" & strScriptFile & "' cannot be found." & vbCrLf & "Transfer cancelled."
      lngMsgStyle = vbCritical + vbOKOnly
      DoCmd.Beep
    Else
      strWinSysDir = Environ("COMSPEC")
      strWinSysDir = Left(strWinSysDir, Len(strWinSysDir) - Len(Dir(strWinSysDir)))
      strMsgPrompt = "Transfer in progress." & vbCrLf & "Press OK here when finished."
      lngMsgStyle = vbExclamation + vbOKOnly
      Call Shell(strWinSysDir & "ftp.exe -s:" & strQuote & strScriptFile & strQuote, vbNormalNoFocus)
    End If
  End If
 
  ' Pause here. Let the user wait for the FTP session to finish.
  MsgBox strMsgPrompt, lngMsgStyle, strMsgTitle

End Sub

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ornekmAuthor Commented:
It works for paths without spaces.  

As thenelson indicated I think the problem is with the spaces in the path info of the target script file.  How do I fix that?
0
ornekmAuthor Commented:
Okay.  I figured it out. Chr(34) additions saved the day.  Thank you all!
0
Gustav BrockCIOCommented:
As he wrote:

    cmdline = Chr(34) & CurrentProject.Path & "\A2006E.BAT" & Chr(34)

/gustav
0
Gustav BrockCIOCommented:
Oh, you think faster than I can write ...

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.