VBA TO SEND TXT FILE TO FTP SERVER

BINOD SHARMA

New Member
Joined
Feb 12, 2020
Messages
5
Office Version
  1. 2007
My Friends, I have downloaded a vba code to send txt file from desktop to ftp server but I unable to understand why it"s not working ?
Can any one help
Sub IP_SERVER_IP()
Dim vPath As String
Dim vFile As String
Dim vFTPServ As String
Dim fNum As Long

vPath = ThisWorkbook.Path
vFile = "BKSSS.txt"
vFTPServ = "ftp://10.44.115.123"

'Mounting file command for ftp.exe
fNum = FreeFile()
Open vPath & "\BKSSS.txt" For Output As #fNum
Print #1, "user ***** *****" ' your login and password"
Print #1, "cd TargetDir" 'change to dir on server
Print #1, "put " & vPath & "\" & vFile & " " & vFile ' upload local filename to server file
Print #1, "close" ' close connection
Print #1, "quit" ' Quit ftp program
Close

Shell "ftp -n -i -g -s:" & vPath & "\BKSSS.txt " & vFTPServ, vbNormalNoFocus

SetAttr vPath & "\BKSSS.txt", vbNormal
Kill vPath & "\BKSSS.txt"
me.

code is -

 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
The code you have downloaded is generic. If you tried to use it without changing anything that would explain why it is not working. Unless you edit it to add *your* specific information (directories, IPaddr, username, password, etc.) it is not going to work for you. The only point of the VBA macro is to automate the commands you would manually use to run FTP, so unless you are able to to open a CMD window:

1664656143024.png


and manually use FTP to successfully transfer files in order to prove that with the correct information, FTP on your PC will work, the odds are against you being able to get the VBA macro to work.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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