|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 借用网上大侠的下载图片()
Dim rng As Range, Cel As Range, xh, myPath, fn$, s() As Byte
Dim imageCol$, nameCol$
Set xh = CreateObject("MSXML2.XMLHTTP")
myPath = [b1].value
If Dir(myPath, vbDirectory) = "" Then MkDir myPath
nameCol = "A" '姓名所在列
imageCol = "B" '图所在列
For i = 2 To [a65536].End(xlUp).Row
fn = myPath & "\" & Cells(i, nameCol).Value & ".jpg"
If Dir(fn) = "" Then
Set Cel = Cells(i, imageCol)
'adr = Cel.Hyperlinks(1).Address
adr = Cel.Value
xh.Open "GET", adr, False
xh.send
s = xh.responsebody
n = FreeFile
Open fn For Binary As #n
Put #n, , s
Close #n
End If
Next
End Sub |
|