VBA Excel 2010 64bit hangs
First off - thank you for providing this interface - i hope to get it working from within a VBA script soon.
I downloaded the library and to test i was able to execute this script from powershell: (Note I did change some of the strings to protect passwords, etc.)
I hope this shows that the DLL is functioning..
Now when I try to execute this VBA script from within Excel 2010 64bit Macro (And I do have the library reference selected) via debug - the mySession and mySessionOptions variables are never set - it is like the "New" option is not finding the objects.
I also ran the .net registration for both 32bit and 64bit per your install_library page.
Thoughts?
I downloaded the library and to test i was able to execute this script from powershell: (Note I did change some of the strings to protect passwords, etc.)
try
{
# Load WinSCP .NET assembly
Add-Type -Path "c:\Program Files (x86)\WinSCP\WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "hostname"
UserName = "*****"
Password = "*****"
SshHostKeyFingerprint = "ssh-rsa 2048 ce:f2:d5:05:e0:36:63:e1:**:**:**:c0:16:ba:06:72"
}
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
# Upload files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferResult = $session.PutFiles("d:\util\junkfolder\*", "/var/lib/user/junkfolder/", $False, $transferOptions)
# Throw on any error
$transferResult.Check()
# Print results
foreach ($transfer in $transferResult.Transfers)
{
Write-Host ("Upload of {0} succeeded" -f $transfer.FileName)
}
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch [Exception]
{
Write-Host $_.Exception.Message
exit 1
}I hope this shows that the DLL is functioning..
Now when I try to execute this VBA script from within Excel 2010 64bit Macro (And I do have the library reference selected) via debug - the mySession and mySessionOptions variables are never set - it is like the "New" option is not finding the objects.
I also ran the .net registration for both 32bit and 64bit per your install_library page.
Thoughts?
Sub TransferFolder()
On Error GoTo SPC_err
' Setup session options
Dim mySessionOptions As New WinSCPnet.SessionOptions
With mySessionOptions
.Protocol = WinSCPnet.Protocol_Sftp
.HostName = "hostname"
.UserName = "******"
.Password = "******"
.SshHostKeyFingerprint = "ssh-rsa 2048 ce:f2:d5:05:e0:36:63:e1:**:**:**:c0:16:ba:06:72"
End With
Dim mySession As New WinSCPnet.Session
' Connect
mySession.Open mySessionOptions
On Error Resume Next
' Upload files
Dim myTransferOptions As New WinSCPnet.TransferOptions
myTransferOptions.TransferMode = WinSCPnet.TransferMode_Binary
Dim transferResult As WinSCPnet.TransferOperationResult
Set transferResult = mySession.PutFiles("d:\util\junkfolder\*", "/var/lib/amavis/junkfolder/", False, myTransferOptions)
' Throw on any error
transferResult.Check
' Display results
Dim transfer As WinSCPnet.TransferEventArgs
For Each transfer In transferResult.Transfers
MsgBox "Upload of " & transfer.Filename & " succeeded"
Next
' Query for errors
If Err.Number <> 0 Then
MsgBox "Error: " & Err.Description
' Clear the error
Err.Clear
End If
' Disconnect, clean up
mySession.Dispose
mySessionOptions.Dispose
' Restore default error handling
On Error GoTo 0
Exit Sub
SPC_err:
MsgBox "Error: " & Err.Description
End Sub