Inserting an Online Picture to Excel with VBA -
i'm working on project , need fill in cells pictures via urls. urls in 1 column, , i'd load images in adjacent column. i'm no vba expert, found code worked, reason error (usually 5 images in) says:
run-time error '1004': unable insert property of pictures class
again, i'm using system urls in 1 column i.e.:
xxxx.com/xxxx1.jpg
xxxx.com/xxxx2.jpg
xxxx.com/xxxx3.jpg
xxxx.com/xxxx4.jpg
through searching, found linked excel version (using 2010), though i'm not sure.
here's current code i'm using:
sub urlpictureinsert() dim cell, shp shape, target range set rng = activesheet.range("a5:a50") ' range urls each cell in rng filenam = cell activesheet.pictures.insert(filenam).select set shp = selection.shaperange.item(1) shp .lockaspectratio = msotrue .width = 100 .height = 100 .cut end cells(cell.row, cell.column + 1).pastespecial next end sub
any appreciated!
original code source: http://www.mrexcel.com/forum/excel-questions/659968-insert-image-into-cell-url-macro.html
this identical solution posted month ago:
excel vba insert images image name in column
sub insertpic() dim pic string 'file path of pic dim mypicture picture 'embedded pic dim rng range 'range on iterate dim cl range 'iterator set rng = range("b1:b7") '<~~ modify range needed. assumes image link url in column a. each cl in rng pic = cl.offset(0, -1) set mypicture = activesheet.pictures.insert(pic) ' 'you can play manipulate size & position of picture. ' shrinks picture fit inside cell. mypicture .shaperange.lockaspectratio = msofalse .width = cl.width .height = cl.height .top = rows(cl.row).top .left = columns(cl.column).left end ' next end sub
Comments
Post a Comment