I created a test file on my D drive. My goal is to upload it to my website from a VBA script in Excel. When I run the .bat file it hangs during the put. What am I doing wrong? I commented out the / line because that was giving me an error.
Reply when running upload.bat from command prompt
D:\>upload.bat
D:\>ftp -i -s:d:\script.dat domain.com
Connected to domain.com.
220 *** FTP Server Ready
200 UTF8 set to on
User (domain.com:(none)):
331 Password required for username
230 User username logged in
ftp> put d:\test.txt
200 PORT command successful
425 Unable to build data connection: Connection timed out
ftp> quit
221 Goodbye.
enter code here
Sub ftp()
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("d:\script.dat", True)
a.writeline "username" 'username
a.writeline "password" 'password
'a.writeline "\" 'directory on FTP site
a.writeline "put d:\test.txt" 'file to be uploaded
a.writeline "quit"
a.Close
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("d:\upload.bat", True)
a.writeline "ftp -i -s:d:\script.dat domain.com" 'the ftp site
a.Close
dRetVal = Shell("d:\upload.bat", 0) 'upload the file
Application.ScreenUpdating = True
End Sub