Using WinSCP .NET Assembly from Visual Basic for Applications (VBA)

Advertisement

Pawan
Customer
Joined:
Posts:
8

Using WinSCP .NET Assembly from Visual Basic for Applications (VBA)

Hi,

I have a paid version of WinSCP from the Microsoft App Store. How do I use this to implement in VBA?

If I follow the instructions on your Downloading and Installing WinSCP .NET Assembly page, does this mean I would have to manually keep updating the files when there are updates?

Sorry if I am now mixing topics, but I want to explain why I wish to use VBA.

Currently, I am using WinSCP to sync local files/folders to my website server. Some files are updated often and need to be uploaded immediately. Many files are generated by Excel VBA. This mostly all works fine. However, occasionally, one my critical files gets uploaded with 0 KB size. I think this is due to a loss of connection during the upload for some reason. When this happens, WinSCP does not detect an error and does not try to upload the file again. I see that others have reported this in the forum, but I couldn't find an obvious resolution. So I want to use VBA to check for this situation and correct it if it happens.

Can you please suggest any easy way to do this?

Any guidance you can provide would be really appreciated.

Thanks!

Reply with quote

Advertisement

Pawan
Customer

I should add that I am currently using the "Keep remote up to date" command to maintain sync between my local computer and my website server. The "Continue on error" is selected and I am using "Enable transfer resume/transfer to temporary filname for All files".

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,602
Location:
Prague, Czechia

Re: Using WinSCP .NET Assembly from Visual Basic for Applications (VBA)

Thanks for supporting WinSCP by purchasing it from the Store.

While the Store installation of WinSCP comes both with scripting and .NET assembly, I'd not recommend to rely on it for automation. With .NET assembly we do not recommend relying on installed version of WinSCP (Store or not).

If you want a help with your other problem, please post logs.

Reply with quote

Pawan
Customer
Joined:
Posts:
8

Thanks for your reply. I will post the log the next time the O KB situation occurs. Fortunately it only occurs occasionally, so I am not sure when it will happen again.

In the meantime, is there any way to watch out for this situation? Is there a setting in WinSCP that monitors file size and when it sees a discrepancy, takes action?

Reply with quote

martin
Site Admin
martin avatar

It's difficult to give any advices, when we do not know how exactly did the zero size occur. Please post the logs, once it happens.

Reply with quote

Advertisement

Pawan
Customer
Joined:
Posts:
8

The 0 KB issue occurred again today.

Please see attached. Focus on the UserList.csv file. See what this is doing. This is the one that seems to have the 0 KB issue.
  • Backup.log (230.35 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,602
Location:
Prague, Czechia

Thanks. It seems that the file did not finish creating/writing (or possibly uploading to OneDrive?) before WinSCP tried to upload it. That definitely deserves improving on WinSCP side:
Issue 2135 – Do not overwrite existing remote file before succeeding to open the local source file with FTP protocol

Meanwhile, try to increase the interval after which WinSCP uploads the file after the change by setting Interface\KeepUpToDateChangeDelay:
https://winscp.net/eng/docs/rawconfig#keepuptodatechangedelay

Reply with quote

Advertisement

You can post new topics in this forum