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:
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