I need VBA code to upload to FTP in Mac OS

Zubair2icy

New Member
Joined
Nov 27, 2022
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
I have an excel VBA code to upload file to FTP server which works on windows, but I need it to work on Mac. I am using MS365. See the code below:

Sub fileToFTP()
Set FSO = CreateObject("scripting.filesystemobject")

'set the pathe and file name of the script to be run
F = "C:\temp\FTPScript.txt"

'Create the ftpscript to be run
Open F For Output As #1
Print #1, "open 111.111.111.111" 'replace ftp.server with the server address
Print #1, "myusername" 'login id here
Print #1, "mypass" 'login password here
Print #1, "pasv" ' passive mode ftp if needed
'change remote directories if needed
'Print #1, "cd " & " /dir" 'Directory of file location
'Print #1, "cd " & " subdir" 'Sub-Directory of file location
Print #1, "ascii"
Print #1, "prompt"
'Put the file from the host and save it to the specified directory and filename
Print #1, "put " & VREDET; """C:\temp\yourFile.xlsx"""; ""
'additional files if needed
'Print #1, "put " & VREDET; """C:\file2.csv"""; ""
'Print #1, "put " & VREDET; """C:\file3.csv"""; ""
Print #1, "disconnect" 'disconnect the session
Print #1, "bye"
Print #1, "exit"
Close #1
'Now for the command to upload to the ftpsite and log it to a text file
' the trick is to use the standard command shell which allows logging

Set FSO = Nothing

Shell "cmd /c C:\WINDOWS\system32\ftp.exe -i -s:C:\temp\FTPScript.txt > c:\temp\ftpuploadlog.txt", vbHide

End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

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