Certain URLs for Inserting Pictures into Excel Sheet Returns a Run Time Error :/

leftysgirlschool

New Member
Joined
Sep 27, 2016
Messages
2
I have a spreadsheet that has some macro that takes picture url's from one column to display in another.
When I run the macro (Not sure if I said that correctly. I am new at this stuff), it goes smoothly until I reach url's that look like these ones:


http://ecx.images-amazon.com/images/I/513aNHvKu3L._SL160_.jpg


http://i.upcindex.com/i/WjI5dlpjMnh...YUTlhbkJsWnlaeGJIUTlNVEF3MnhsYzNWamEzTQ,,.jpg


I then receive a Run Time error and the program stops working.
When I click on these urls or paste them into a browser an image does appear.


Is there a way to get the macro to be a little more forgiving with these kind of urls? So, that I can pull the images from them. I am pulling out my hair over here.


Here's the code I am using:


Code:
 Sub InstallPictures() 
    Application.ScreenUpdating = False 
    Application.Calculation = xlCalculationManual 
    Dim url_column As Range 
    Dim image_column As Range 
     'column with url...
    Set url_column = Worksheets(1).UsedRange.Columns("V") 
     'column where image will be inserted
    Set image_column = Worksheets(1).UsedRange.Columns("W") 
    Dim i As Long 
    For i = 2 To url_column.Cells.Count 
        Set Picture = image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value) 
        Picture.Left = image_column.Cells(i).Left 
        Picture.Top = image_column.Cells(i).Top 
        Picture.Height = 40 
        image_column.Cells(i).EntireRow.RowHeight = 40 
    Next 
    Application.ScreenUpdating = True 
    Application.Calculation = xlCalculationAutomatic 
    End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,215,723
Messages
6,126,470
Members
449,315
Latest member
misterzim

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