I have code that successfully does the following:
Column A has a set of URLs for web-based images, Column B is where the images get pasted after running the macro.
The problem I have is that the URLs are not always accurate because the heirarchy can change slightly, for instance I may have a URL that looks like this: http://www.excelforum.com/images/sidebar/home.png
the image may actually exist in
http://www.excelforum.com/images/sidebar1/home.png OR
http://www.excelforum.com/images/sidebar2/home.png OR
http://www.excelforum.com/images/sidebar3/home.png OR
http://www.excelforum.com/images/sidebar4/home.png
Basically a subfolder can iterate by +1. I need to write exception handling in the code that will run through a limited number of folders (1-12) until it doesnt error out (image found successfully) (Currently if an image doesnt exist in the specific URL location then a '400' error occurs) Any suggestions appreciated
Existing code below and in attached example
Sub PlaceImageInCell2()
Dim url_column As Range
Dim image_column As Range
Set url_column = Worksheets(1).UsedRange.Columns("A")
Set image_column = Worksheets(1).UsedRange.Columns("B")
Dim i As Long
For i = 1 To url_column.Cells.Count
With image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)
.Left = image_column.Cells(i).Left
.Top = image_column.Cells(i).Top
image_column.Cells(i).EntireRow.RowHeight = .Height
End With
Next
End Sub
Bookmarks