VBA using session.MoveFile
I am using VBA within Access to upload a file to SFTP which works fine.
I need to rename the file on the SFtp site is that possible using the VBA methods?
I keep getting "Object required" below is the code:
I need to rename the file on the SFtp site is that possible using the VBA methods?
I keep getting "Object required" below is the code:
Private Sub Upload(ByRef mySession As Session) ' Setup session options Dim mySessionOptions As New SessionOptions With mySessionOptions .Protocol = Protocol_Sftp .HostName = "ftp.xxxxxxxxxxxxxx.net" .UserName = "xxxxxxx" .Password = "xxxxxxxx" .SshHostKey = "ssh-dss 1024 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" End With ' Get file name Dim strFile As String strFile = Dir("\\xxx.xxx.1.3\Corp\IT\scripts\Credit\SendTest\*.u01") ' Connect mySession.DisableVersioncheck = True mySession.Open mySessionOptions ' Upload files Dim myTransferOptions As New TransferOptions myTransferOptions.TransferMode = TransferMode_Binary Dim transferResult As TransferOperationResult Dim myMoveResult As SessionRemoteException Set transferResult = mySession.PutFiles("\\xxx.xxx.1.3\Corp\IT\scripts\Credit\SendTest\" & strFile & "", strFile, False, myTransferOptions) 'GET ERROR HERE*********************************************************** Set myMoveResult = mySession.MoveFile(strFile, "cz311660.r01") ' Throw on any error transferResult.Check ' Display results Dim intSuccess As Integer Dim transfer As TransferEventArgs For Each transfer In transferResult.Transfers MsgBox "Upload of " & transfer.FileName & " succeeded!" intSuccess = 1 Next If intSuccess <> 1 Then Err.Raise 999, , "Failed to upload file!" 'MsgBox "File did not send properly." End If End Sub