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:

OPEN {addres}
lcd W:\PerformanceMeasures\Monthly Reports
MGET S200602*.mdb

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,

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.

A batch file run in shell needs to have quotation marks around it:
                cmdline = "" & CurrentProject.Path & "\A2006E.BAT"""
You would also need the qoutation marks if CurrentProject.Path has spaces in it.
ornekmAuthor Commented:
I tried both of your suggestions.  Still nothing.
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.

Put a code break on
              Shell cmdline, vbMaximizedFocus
in the immediate pane.  It should show

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

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
    If Len(Dir(strScriptFile)) = 0 Then
      strMsgPrompt = "Script file '" & strScriptFile & "' cannot be found." & vbCrLf & "Transfer cancelled."
      lngMsgStyle = vbCritical + vbOKOnly
      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


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?
ornekmAuthor Commented:
Okay.  I figured it out. Chr(34) additions saved the day.  Thank you all!
Gustav BrockCIOCommented:
As he wrote:

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

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

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.