|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
不喜欢拿python到这里踩场,vba也可以批量下载图片的,严重怀疑你开车!
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
Public Declare Function DeleteUrlCacheEntry Lib "wininet" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
Sub test1()
Dim nUrl As String, localFilename As String, lngRetVal As Long, i
For i = 1 To 100
nUrl = "https://gitee.com/kevin2046/picture/raw/master/img/" & i & ".jpg"
localFilename = ThisWorkbook.Path & Application.PathSeparator & i & ".jpg"
DeleteUrlCacheEntry nUrl
lngRetVal = URLDownloadToFile(0, nUrl, localFilename, 0, 0)
If lngRetVal <> 0 Then
MsgBox "失败"
End If
Next i
MsgBox "OK"
End Sub |
|