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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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