Help using Session.FileTransferProgress Event within VBA module
I am having trouble figuring out a way to use the FileTransferProgress to return a status of how the download is progressing.
I would like to be able to see somewhere (debug screen for now) how far along a download is as some of the files are taking a long time to download and I would like to know that things are still progressing. Due to my lack of knowledge of classes, powershell, VB.net and C#, i don't know how to translate the examples you provided into VBA, so I thought I would put it out here to see if someone can lend a hand.
Here's what I got so far:
The code works great, but on the line:
the code 'freezes' there until all the downloads are finished (I am downloading around 38 files totalling around 1.5GB).
How do I enhance this to print (debug.print) the percent completion of a download?
Thanks,
Tom
I would like to be able to see somewhere (debug screen for now) how far along a download is as some of the files are taking a long time to download and I would like to know that things are still progressing. Due to my lack of knowledge of classes, powershell, VB.net and C#, i don't know how to translate the examples you provided into VBA, so I thought I would put it out here to see if someone can lend a hand.
Here's what I got so far:
Sub wsDownload(myProtocol As Integer, myFTP As String, myUserName As String, myPassword As String, _ LocalDirectory As String, RemoteDirectory As String, Optional RemoteFile As String) Dim mySession As New Session Dim mySessionOptions As New SessionOptions Dim myTransferOptions As New TransferOptions Dim transferResult As TransferOperationResult Dim transfer As TransferEventArgs If RemoteFile = "" Then RemoteFile = "*.*" ' Setup session options With mySessionOptions .Protocol = myProtocol .HostName = myFTP .UserName = myUserName .Password = myPassword '.sshhostkeyfingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" End With ' Connect mySession.Open mySessionOptions ' Download files myTransferOptions.TransferMode = TransferMode_Binary Set transferResult = mySession.GetFiles(RemoteDirectory & RemoteFile, LocalDirectory) ' Throw on any error transferResult.Check ' Display results For Each transfer In transferResult.Transfers 'MsgBox "Download of " & transfer.FileName & " succeeded" & "," & transfer.destination Next ' Disconnect, clean up mySession.Dispose End Sub
The code works great, but on the line:
Set transferResult = mySession.GetFiles(RemoteDirectory & RemoteFile, LocalDirectory)
How do I enhance this to print (debug.print) the percent completion of a download?
Thanks,
Tom