Hi all,
trying to download multiple files from a FTP server. Currently I can download one file from the FTP server but I struggle to modify the code to my needs.
I have the following code:
The issue, I am facing is that the filename changes every week since it has a timestamp. The filename structure is:
I already tried to use:
This did not work.
I am looking for a solution where the folder name is calculated by the current week number and the macro downloads all files from this folder.
Thanks for your help!
trying to download multiple files from a FTP server. Currently I can download one file from the FTP server but I struggle to modify the code to my needs.
I have the following code:
VBA Code:
Option Explicit
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Declare PtrSafe Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
Public Sub test1a() 'ohne Dialog
Call URLDownloadToFile(0, "ftp://UserName:Passwort@ftp.abc.de/Week_202251/1_REPORT.ABC_20.12.22.07.32_202251.csv", _
"C:/Users/xyz/Downloads/1_REPORT.ABC_20.12.22.07.32_202251.csv", 0, 0)
End Sub
The issue, I am facing is that the filename changes every week since it has a timestamp. The filename structure is:
- 1_REPORT.ABC_TimeStamp
- 2_REPORT.ABC_TimeStamp
- 3_REPORT.ABC_TimeStamp
- 4_REPORT.ABC_TimeStamp
- 5_REPORT.ABC_TimeStamp
I already tried to use:
VBA Code:
Call URLDownloadToFile(0, "ftp://UserName:Passwort@ftp.abc.de/Week_202251/1_REPORT.ABC*.csv", .........
This did not work.
I am looking for a solution where the folder name is calculated by the current week number and the macro downloads all files from this folder.
Thanks for your help!