我目前正在一个项目中工作,需要通过URL填充单元格中的图片。所有的URL都在一列中,我想在相邻的一列中加载这些图像。虽然我不是VBA专家,但我找到了一些代码可以使用,但是出现了一个错误(通常在5张图像后),错误信息如下:
运行时错误 '1004': 无法获取Pictures类的Insert属性
再次强调,我使用的是一个系统,其中URL在一列中,例如:
xxxx.com/xxxx1.jpg
xxxx.com/xxxx2.jpg
xxxx.com/xxxx3.jpg
xxxx.com/xxxx4.jpg
通过搜索,我发现这可能与我的Excel版本有关(使用2010版),尽管我不完全确定。
以下是我正在使用的当前代码:
非常感谢您的帮助!
原始代码来源:http://www.mrexcel.com/forum/excel-questions/659968-insert-image-into-cell-url-macro.html
运行时错误 '1004': 无法获取Pictures类的Insert属性
再次强调,我使用的是一个系统,其中URL在一列中,例如:
xxxx.com/xxxx1.jpg
xxxx.com/xxxx2.jpg
xxxx.com/xxxx3.jpg
xxxx.com/xxxx4.jpg
通过搜索,我发现这可能与我的Excel版本有关(使用2010版),尽管我不完全确定。
以下是我正在使用的当前代码:
Sub URLPictureInsert()
Dim cell, shp As Shape, target As Range
Set Rng = ActiveSheet.Range("a5:a50") ' range with URLs
For Each cell In Rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select
Set shp = Selection.ShapeRange.Item(1)
With shp
.LockAspectRatio = msoTrue
.Width = 100
.Height = 100
.Cut
End With
Cells(cell.Row, cell.Column + 1).PasteSpecial
Next
End Sub
非常感谢您的帮助!
原始代码来源:http://www.mrexcel.com/forum/excel-questions/659968-insert-image-into-cell-url-macro.html
filenam
的值是多少? - Siddharth Rout