Michaelpfreem
Board Regular
- Joined
- Mar 14, 2008
- Messages
- 92
Dear all,
I have some code to upload some data to an FTP site but it doesn't seem to work, everything I have seen on the net would suggest it should do what I want, but it doesn't appear so.
Basically I want to upload a file stored on my computer to an FTP site, my code is below:
Sub FTPupload()
Dim dRetVal As Variant
Dim aaa As Object, a As Variant
Dim bbb As Object, b As Variant
'write script.dat and upload.dat file
Set aaa = CreateObject("Scripting.FileSystemObject")
Set a = aaa.CreateTextFile("C:\folder\folder\script.dat", True)
a.writeline "username" 'username
a.writeline "password" 'password
a.writeline "put C:\folder\folder\filename.xls" 'file to be uploaded
a.writeline "quit"
a.Close
Set bbb = CreateObject("Scripting.FileSystemObject")
Set b = bbb.CreateTextFile("C:\folder\folder\upload.bat", True)
b.writeline "ftp -i -s:c:\folder\folder\script.dat ftp://00.000.000.00/FolderTest" 'the ftp site
b.Close
dRetVal = Shell("C:\folder\folder\upload.bat", 1) 'upload the file
End Sub
I am open to other suggestions on how to move files around from PC to FTP using excel VBA; but I am putting my code up here as a starting point.
Many thanks in advance,
Mike
I have some code to upload some data to an FTP site but it doesn't seem to work, everything I have seen on the net would suggest it should do what I want, but it doesn't appear so.
Basically I want to upload a file stored on my computer to an FTP site, my code is below:
Sub FTPupload()
Dim dRetVal As Variant
Dim aaa As Object, a As Variant
Dim bbb As Object, b As Variant
'write script.dat and upload.dat file
Set aaa = CreateObject("Scripting.FileSystemObject")
Set a = aaa.CreateTextFile("C:\folder\folder\script.dat", True)
a.writeline "username" 'username
a.writeline "password" 'password
a.writeline "put C:\folder\folder\filename.xls" 'file to be uploaded
a.writeline "quit"
a.Close
Set bbb = CreateObject("Scripting.FileSystemObject")
Set b = bbb.CreateTextFile("C:\folder\folder\upload.bat", True)
b.writeline "ftp -i -s:c:\folder\folder\script.dat ftp://00.000.000.00/FolderTest" 'the ftp site
b.Close
dRetVal = Shell("C:\folder\folder\upload.bat", 1) 'upload the file
End Sub
I am open to other suggestions on how to move files around from PC to FTP using excel VBA; but I am putting my code up here as a starting point.
Many thanks in advance,
Mike