基本上我正在編寫一個從列表中抓取圖像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