Extracting hyperlink destinations from Excel (Document Library item URLs)
I recently needed the destination URL for several hundred items across layers of nested folders in a giant SharePoint Document Library. Right clicking with “copy link location” just wasn’t going to work here. The datasheet view, Excel, and Access all came to mind as possible tools. In then end a quick Excel UDF (User Defined Function) helped get the job done. This is easily done against SharePoint Document Libraries because the default Title column links to the file item URL.
- Choose “Export to Spreadsheet” from your document library
- Open the .IQY file when prompted
- Press Alt+F11, then Insert > Module
- Paste in this code:
- Save the workbook. Note: You might be prompted to save as XLSM for a macro enabled workbook, change the file type, and save.
- Use the =getaddress(cell) function to see the URLs (screenshots below)
Function GetAddress(HyperlinkCell As Range) GetAddress = Replace _ (HyperlinkCell.Hyperlinks(1).Address, "mailto:", "") End Function
Function GetAddress(HyperlinkCell As Range)
GetAddress = Replace _
(HyperlinkCell.Hyperlinks(1).Address, "mailto:", "")