Appending files on FTP site using VBA

elmonko

New Member
Joined
Dec 18, 2012
Messages
25
Hi,

I currently have the following which creates a script and uploads a text file to an FTP site

Code:
Set TextFile = CreateObject("Scripting.FileSystemObject").CreateTextFile(scriptfile, True)
TextFile.writeline "user@mywebsite.co.uk"     'username
TextFile.writeline "password!" 'password
TextFile.writeline "cd GK" 'directory on FTP site
TextFile.writeline "binary"
TextFile.writeline "put " + Chr(34) + "c:\temp\IDCheck.txt" + Chr(34) 'file to be uploaded
TextFile.writeline "bye"
TextFile.Close

Code:
Set TextFile = CreateObject("Scripting.FileSystemObject").CreateTextFile(batfile, True)
TextFile.writeline "ftp -s:" + Chr(34) + scriptfile + Chr(34) + " www.mywebsite.co.uk"
TextFile.writeline "del " + Chr(34) + "c:\temp\IDCheck.txt" + Chr(34)
TextFile.writeline "del " + Chr(34) + scriptfile + Chr(34)
TextFile.writeline "del " + Chr(34) + batfile + Chr(34)
TextFile.Close

The file
c:\temp\IDCheck.txt
is created everytime an excel spreadsheet is opened and contains a single cell value. I would like to append the contents of the text file on the FTP as currently it just gets overwritten. Is this possible
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Yes. Do a get for the file from the FTP site first. Append your data to the end of it. Then upload it.
 
Upvote 0
According to the FTP RFC (http://www.ietf.org/rfc/rfc959.txt) there is an append command but I have never used it. So you could try changing the "put" in your code to "append" and see what happens.


APPEND (with create) (APPE)

This command causes the server-DTP to accept the data
transferred via the data connection and to store the data in
a file at the server site. If the file specified in the
pathname exists at the server site, then the data shall be
appended to that file; otherwise the file specified in the
pathname shall be created at the server site.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top