Multiple Hyperlink Source Code Import

Tap13

New Member
Joined
Apr 13, 2010
Messages
35
I have a list of about 40 hyperlinks. I need to retrieve the source code from each of these links. I would then like to have each page pasted into excel. I currently have the 40 hyperlinks within a spreadsheet.

I can currently view a page within firefox, right click, view source code, copy the code, and when I hit paste in Excel it doesn't actually show up as line by line code, it formats it to replicate the page including that pages hyperlinks.

My ultimate goal is to retrieve the 50 links per page across 40 pages so I can sort them alphabetically for some analysis. Is it possible to automate this with a macro, or will I be stuck going page by page?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
This code will document all hyperlinks in a workbook on a new worksheet. There are several more hyperlink properties available.
Code:
Sub DocumentHyperlinks()

    Dim lX As Long
    Dim lY As Long
    Dim lNextWriteRow As Long
    
    ThisWorkbook.Activate
    
    On Error Resume Next
    Application.DisplayAlerts = False
    Worksheets("Document Hyperlinks").Delete
    Application.DisplayAlerts = True
    On Error GoTo 0
    Worksheets.Add(before:=Sheets(1)).Name = "Document Hyperlinks"
    
    Worksheets("Document Hyperlinks").Range("A1").Resize(1, 5).Value = Array("TextToDisplay", "Range.Worksheet.Name", "Range.Address", "Address", "SubAddress")
    lNextWriteRow = 2
    For lX = 1 To ThisWorkbook.Worksheets.Count
        With Worksheets(lX)
            For lY = 1 To .Hyperlinks.Count
                Worksheets("Document Hyperlinks").Cells(lNextWriteRow, 1) = .Hyperlinks(lY).TextToDisplay
                Worksheets("Document Hyperlinks").Cells(lNextWriteRow, 2) = .Hyperlinks(lY).Range.Worksheet.Name 'Worksheet Hyperlink is on
                Worksheets("Document Hyperlinks").Cells(lNextWriteRow, 3) = .Hyperlinks(lY).Range.Address 'Address on that worksheet
                Worksheets("Document Hyperlinks").Cells(lNextWriteRow, 4) = .Hyperlinks(lY).Address 'Workbook Destination of hyperlink (blank for same workbook)
                Worksheets("Document Hyperlinks").Cells(lNextWriteRow, 5) = .Hyperlinks(lY).SubAddress 'Destination Worksheet & Address
                
                lNextWriteRow = lNextWriteRow + 1
            Next
        End With
    Next
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,802
Messages
6,181,054
Members
453,014
Latest member
Chris258

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