基本上我正在编写一个从列表中抓取图像URL的代码,并在单元格中输出它们的大小。它适用于一些链接,但不是全部。有人能告诉我为什么是这样吗?如何使用vba保持原始图像大小?
Dim MyPic As Shape
Dim sht As Worksheet
Set sht = ActiveSheet
With sht
For i = 2 To .Cells(.Rows.Count, "A").End(xlUp).Row
If .Cells(i, 2) <> "" Then
Set mypict = ActiveSheet.Shapes.AddPicture(.Cells(i, 2).Text, _
msoFalse, msoTrue, 3, 3, -1, -1)
'Set mypict = ActiveSheet.Pictures.Insert(.Cells(i, 2).Text)
.Cells(i, 7) = mypict.Width & " x " & mypict.Height
mypict.Delete
End If
Next i
End With
最好的问候,
旧金山
嗯它为我工作。你可以分享一个URL或三个地方它*不*工作? – BruceWayne
http://res.cloudinary.com/lo65iitez/image/upload/v1437773949/OMS/MHI-90102-YELLOW_full.jpg –
您可能想看看@David Zemens提供的程序代码vide question url获得的样本结果上传到下拉框视频链接请检查它是否符合您的要求。它通过设置LockAspectRatio照顾图像的大小 –
skkakkar