Image of data in excel我使用超鏈接從網上下載一些數據,並將下載的數據放入使用A列中列出名稱創建的文件夾中。從超鏈接下載數據到使用vba創建新文件夾
現在當一個文件夾只有一個超鏈接時數據成功下載,但現在我也想將超過2個文件數據放入同一個文件夾。
任何人都可以提出一種方法來增強代碼,以允許?
Option Explicit
Private Declare 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
Dim ret As Long
'> This is where the files will be saved. Change as applicable
Const FolderName As String = "C:\Users\a3rgcw\Downloads\"
Sub Download()
Dim ws As Worksheet
Dim lastRow As Long, i As Long
Dim strPath As String
Set ws = Sheets("Sheet1")
lastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To lastRow
strPath = FolderName & ws.Range("A" & i).Value & ".zip"
ret = URLDownloadToFile(0, ws.Range("D" & i).Value, strPath, 0, 0)
If ret = 0 Then
ws.Range("F" & i).Value = "PR data successfully downloaded"
Else
ws.Range("F" & i).Value = "Unable to download PR data"
End If
Next i
End Sub
顯示您的實際數據和所需行爲的示例 – user3598756
Plz在文本中查找圖像鏈接。 –
和你想要發生什麼? – user3598756