+ Reply to Thread
Results 1 to 1 of 1

Exception/Error Handling to fetch URL images

  1. #1
    Registered User
    Join Date
    06-04-2008
    Posts
    13

    Exception/Error Handling to fetch URL images

    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
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Exception Handling through Macros
    By swathidas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2012, 07:08 PM
  2. Exception Handling of invalid email address
    By ncduke in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-09-2010, 12:32 PM
  3. VBA Macro to fetch images based on URLs in sheet
    By jhodges in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2010, 08:38 AM
  4. Excel Exception handling Macro
    By coder_arun in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2006, 09:00 AM
  5. Error handling with a handling routine
    By ben in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-15-2005, 11:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1