Re: VBA Excel 2010 64bit hangs
I'm sorry, but I do not know how to help you further.
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1023</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2016-03-03T16:33:33.000000000Z" />
<EventRecordID>85015</EventRecordID>
<Channel>Application</Channel>
<Computer>CTS</Computer>
<Security />
</System>
- <EventData>
<Data>.NET Runtime version 2.0.50727.5485 - CLR: Fatal Execution Engine Error (000007FEED75600A) (80131506)</Data>
</EventData>
</Event>
With
statement to separate statements?
.Protocol = WinSCPnet.Protocol_Sftp
syntax. Did you try .Protocol = Protocol_Sftp
, as documented?
why does the code hang on the next statement?
What statement?
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
why does the code hang on the next statement?
the mySession and mySessionOptions variables are never set
What does that mean? Does the code even compile/run? Or does it fail on run time? With what error?
the mySession and mySessionOptions variables are never set
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
}
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