ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ftp --- VBA (https://www.excelbanter.com/excel-programming/375618-ftp-vba.html)

Himansu

ftp --- VBA
 
Hello everyone,

Is it possible to ftp to a location and
prompt the user for the remote file
and where to save the file locally?
(text transfer).

Thanks in advance.

--
Himansu



[email protected]

ftp --- VBA
 
First step:

create and test a script to ftp a file:

open mydomain.com
user myusername mypassword
binary
cd /tmp
put C:/myfilethatiwant2ftp.txt
quit
EOF

Replace variables having names my* with your counterparts.
Save file. Give it a .scr suffix. Example

C:/mydoftp.scr

Execute the following command to test mydoftp.scr

c:\windows\system32\ftp.exe -n -s:mydoftp.scr

Step 2:

Use Excel VBA to create mydoftp.scr

Sub WriteStr(str As String, basename As String)
Dim DoWrite As Boolean
Dim DoBreak As String
DoWrite = True
If DoWrite Then
Open "C:\mydoftp.scr" For Output As #1
Print #1, str
Close #1
End If
DoBreak = ""
End Sub

The variable str should be a string consisting of the revised test
script.

Google this newsgroup about how to execute a shell command from Excel.
Make it so that Excel calls c:\windows\system32\ftp.exe -n
-s:mydoftp.scr

Hello everyone,

Is it possible to ftp to a location and
prompt the user for the remote file
and where to save the file locally?
(text transfer).

Thanks in advance.

--
Himansu




All times are GMT +1. The time now is 07:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com