+ Reply to Thread
Results 1 to 2 of 2

extract urls from hyperlinked images

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    extract urls from hyperlinked images

    I have a list of about 1000 documents and folders each with an associated picture embedded with a hyperlink. I am trying to extract the hyperlinks from those pictures and keep them aligned with thier associated document/folder.

    the following macro, originally posted by Leith Ross in 2005:

    Sub GetHyperlinks()
    
      Dim NextRow As Long
      Dim Shp As Object
      
        NextRow = 1
        
        For Each Shp In ActiveSheet.Shapes
          If Shp.Type = msoPicture Then
            Cells(NextRow, "A") = Shp.Hyperlink.Address
            NextRow = NextRow + 1
          End If
        Next Shp
        
    End Sub
    worked really well, except that it seems to duplicate all of the true urls. when i run the macro on my full list, i end up with 1000 extra urls, and matching them up to their associated doc/folder is nearly impossible.

    Also of note, when it duplicates the url, it often adds one more space to the front, so removing duplicates doesn't really seem to help.

    please help?
    Attached Files Attached Files
    Last edited by simarui; 01-18-2012 at 04:11 PM. Reason: solved

  2. #2
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: extract urls from hyperlinked images

    I kept looking and found it elsewhere, but just in case someone else stumbles here ...

    Sub Test1()
    Application.ScreenUpdating = False
    Dim Sh As Shape
    For Each Sh In ActiveSheet.Shapes
    With Sh
    If Left(.Name, 7) = "Picture" Then
    On Error Resume Next
    Range(.TopLeftCell.Address).Offset(0, 3).Value = .Hyperlink.Address
    On Error GoTo 0
    End If
    End With
    Next Sh
    Application.ScreenUpdating = True
    End Sub
    This did exactly what i wanted. fairly confident the error trap there helped alot.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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