![]() ![]() 'FTPcommand = "cmd /k ftp -n -s:" & Chr(34) & FTPcommandsFile & Chr(34) 'Or, for debugging - cmd /k keeps the command window open must close it manually to continue VBA execution Ret = wsh.Run(Command:=FTPcommand, WindowStyle:=0, WaitOnReturn:=True) '0 = hide command window Print #filenum, "get " & Chr(34) & strRemoteFile & Chr(34)įTPcommand = "cmd /c ftp -n -s:" & Chr(34) & FTPcommandsFile & Chr(34) ![]() Print #filenum, "lcd " & Chr(34) & Left(strLocalFile, InStrRev(strLocalFile, "\") - 1) & Chr(34) 'set local folder ![]() Print #filenum, "user " & strUser & " " & strPass Print #filenum, "open " & strHost & " " & lngPort Open FTPcommandsFile For Output As #filenum ".uk", 21, "mpc0001", "T5smB vbNullString Then Kill strLocalFileįTPcommandsFile = Environ("temp") & "\FTP_commands.txt" If FtpGetFileA(hConn, strRemoteFile, strLocalFile, 1, 0, FTP_TRANSFER_TYPE_UNKNOWN Or INTERNET_FLAG_RELOAD, 0) ThenįtpDownload "/ProductExport_mpc0001.zip", "C:\Users\JohnGlanville\OneDrive - MPC Embroidery\Desktop\Customers\BTCTest\ProductExport_mpc0001.zip", _ HConn = InternetConnectA(hOpen, strHost, lngPort, strUser, strPass, 1, 0, 2) HOpen = InternetOpenA("FTPGET", 1, vbNullString, vbNullString, 1) Sub FtpDownload(ByVal strRemoteFile As String, ByVal strLocalFile As String, ByVal strHost As String, ByVal lngPort As Long, ByVal strUser As String, ByVal strPass As String) Private Declare PtrSafe Function InternetCloseHandle Lib "wininet" ( _ Private Declare PtrSafe Function FtpGetFileA Lib "wininet.dll" ( _ Private Declare PtrSafe Function InternetConnectA Lib "wininet.dll" ( _ Private Declare PtrSafe Function InternetOpenA Lib "wininet.dll" ( _ Private Const INTERNET_FLAG_RELOAD As Long = &H80000000 Private Const FTP_TRANSFER_TYPE_UNKNOWN As Long = 0 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |