Differences
This shows you the differences between the selected revisions of the page.
2020-06-19 | 2021-09-23 | ||
is for windows only + clarify that it's not only for extensions (martin) | no summary (165.225.113.32) (hidden) (untrusted) | ||
Line 186: | Line 186: | ||
See [[library_com_wsh#vbscript|overall VBScript example]] or [[library_examples|any other VBScript example]]. | See [[library_com_wsh#vbscript|overall VBScript example]] or [[library_examples|any other VBScript example]]. | ||
- | ==== [[vba]] VBA Example ==== | + | Option Explicit |
- | See [[library_vb#example|overall VBA example]]. | + | |
+ | Sub Example() | ||
+ | |||
+ | Dim mySession As New Session | ||
+ | |||
+ | ' Enable custom error handling | ||
+ | On Error Resume Next | ||
+ | |||
+ | Upload mySession | ||
+ | |||
+ | ' Query for errors | ||
+ | If Err.Number <> 0 Then | ||
+ | MsgBox "Error: " & Err.Description | ||
+ | |||
+ | ' Clear the error | ||
+ | Err.Clear | ||
+ | End If | ||
+ | |||
+ | ' Disconnect, clean up | ||
+ | mySession.Dispose | ||
+ | |||
+ | ' Restore default error handling | ||
+ | On Error GoTo 0 | ||
+ | |||
+ | End Sub | ||
+ | Private Sub Upload(ByRef mySession As Session) | ||
+ | |||
+ | ' Setup session options | ||
+ | Dim mySessionOptions As New SessionOptions | ||
+ | With mySessionOptions | ||
+ | .Protocol = Protocol.sftp | ||
+ | .HostName = "ftp2-dhllink.dhl.com" | ||
+ | .UserName = "a2aomslowtier_sftp" | ||
+ | .Password = "PnxAPNKp8Tp45hXW" | ||
+ | .SshHostKeyFingerprint = "ssh-rsa 2048 rUHNM1B9cQfUrB9aulY2VrfxtKZ4YRm6xrP5o5TDPc8=" | ||
+ | |||
+ | End With | ||
+ | |||
+ | ' Connect | ||
+ | mySession.Open mySessionOptions | ||
+ | |||
+ | ' Upload files | ||
+ | Dim myTransferOptions As New TransferOptions | ||
+ | myTransferOptions.TransferMode = TransferMode_Binary | ||
+ | |||
+ | Dim transferResult As TransferOperationResult | ||
+ | Set transferResult = _ | ||
+ | mySession.PutFiles("C:\Temp\*", "/in/", False, myTransferOptions) | ||
+ | |||
+ | ' Throw on any error | ||
+ | transferResult.Check | ||
+ | |||
+ | ' Display results | ||
+ | Dim transfer As TransferEventArgs | ||
+ | For Each transfer In transferResult.Transfers | ||
+ | MsgBox "Upload of " & transfer.Filename & " succeeded" | ||
+ | Application.InputBox ("OK") | ||
+ | |||
+ | Next | ||
+ | |||
+ | End Sub | ||
==== [[perl]] Perl Example ==== | ==== [[perl]] Perl Example ==== |