Can I use Session.EnumerateRemoteFiles() in VBA?
I have browsed the forum and found some posts that stated it should be possible
(as in the final post in this thread https://winscp.net/forum/viewtopic.php?t=23824)
but in the docs I read
https://winscp.net/eng/docs/library_session_enumerateremotefiles
However, the outcome:
How would I check for the existence of a remote file of which I only know part of the name (e.g. where the timestamp cannot be predetermined).
I found that cannot be used with wildcards and the common answer is to use instead, but I'm always getting an Automation Error (-2146233079)
e.g.
The problem doesn't seem to be the call itself but the assignment.
When I merely do
the call works, but I'm unable to "catch" the enumerator the call is supposed to return.
I'm on Win10 64bit Enterprise, MS Office 2016 64bit, WinSCPnet.dll (FileVersion 1.7.2.10240, ProductVersion 5.17.1.0)
(as in the final post in this thread https://winscp.net/forum/viewtopic.php?t=23824)
but in the docs I read
https://winscp.net/eng/docs/library_session_enumerateremotefiles
The method cannot be used via COM interface (i.e. from VBScript, JScript or VBA).
However, the outcome:
How would I check for the existence of a remote file of which I only know part of the name (e.g.
SomeFile_<YYYYMMDD_hhmmss>.CSV
I found that
FileExists()
EnumerateRemoteFiles()
e.g.
' passing in "SomeFile_*.CSV" for fileName and a working session Private Function resultExists(fileName As String, ByRef activeSession As Session) As Boolean Dim files As New RemoteFileInfoCollection Dim f As RemoteFileInfo ' error occures when the following statement is executed Set files = activeSession.EnumerateRemoteFiles("/somePath/", fileName, EnumerationOptions_None) resultExists = (files.count > 0) For Each f In files Debug.Print f.Name Next f End Function
The problem doesn't seem to be the call itself but the assignment.
When I merely do
call activeSession.EnumerateRemoteFiles("/somePath/", fileName, EnumerationOptions_None)
I'm on Win10 64bit Enterprise, MS Office 2016 64bit, WinSCPnet.dll (FileVersion 1.7.2.10240, ProductVersion 5.17.1.0)