Insert image into cell by URL macro

iindie

New Member
Joined
Sep 18, 2012
Messages
5
I am facing a bit of a challenge here ,

I would like excel to load pictures from the internet into a cell for example our item code is 2220 present into $A$1 and by macro the picture located at http://www.biesse.net/imagesmini/2220.jpg would be inserted into the next cell $A$2. I have been looking around the forums and unfortunately with partial results at this point in time .

Thanking you for your time and attention and waiting to read from you soon ,

Best Regards,
iindie
 
Dear patel45, your code works perfectly till moment there is missing a picture, than I will get back an error and macro stops. Could you help me avoid this? Thanks Milos
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Code:
Sub b() 
Dim cell, shp As Shape, target As Range
    myurl = "http://www.biesse.net/imagesmini/"
    Set Rng = ActiveSheet.Range("a2:a4") ' range with names
    For Each cell In Rng
       filenam = myurl & cell & ".jpg"
       ActiveSheet.Pictures.Insert(filenam).Select

      Set shp = Selection.ShapeRange.Item(1)
       With shp
          .LockAspectRatio = msoTrue
          .Width = 50
          .Height = 50
          .Cut
       End With
       Cells(cell.Row, cell.Column + 1).PasteSpecial
    Next
    
End Sub

How would I modify this so I could pull an image from any URL without modifying the macro every time and only by pasting the url into a predetermined cell?
 
Last edited:
Upvote 0
Code:
Sub b()
Dim cell, shp As Shape, target As Range
    myurl = "http://www.biesse.net/imagesmini/"
    Set Rng = ActiveSheet.Range("a2:a4") ' range with names
    For Each cell In Rng
       filenam = myurl & cell & ".jpg"
       ActiveSheet.Pictures.Insert(filenam).Select

      Set shp = Selection.ShapeRange.Item(1)
       With shp
          .LockAspectRatio = msoTrue
          .Width = 50
          .Height = 50
          .Cut
       End With
       Cells(cell.Row, cell.Column + 1).PasteSpecial
    Next
  
End Sub

Resurrecting an old post here, got this to work, but I would like it to run until it hits a blank cell in the column where the image numbers are. This would be so I would not have to edit the range of cells every time I run the macro.
 
Upvote 0

Forum statistics

Threads
1,223,577
Messages
6,173,160
Members
452,503
Latest member
AM74

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top