+ Reply to Thread
Results 1 to 5 of 5

Hyperlinks

Hybrid View

karlbf Hyperlinks 10-04-2018, 03:16 AM
FDibbins Re: Hyperlinks 10-04-2018, 04:10 PM
CK76 Re: Hyperlinks 10-04-2018, 05:01 PM
Zer0Cool Re: Hyperlinks 10-04-2018, 06:30 PM
CK76 Re: Hyperlinks 10-04-2018, 06:39 PM
  1. #1
    Registered User
    Join Date
    08-26-2012
    Location
    stoke on trent
    MS-Off Ver
    Excel 2016
    Posts
    8

    Hyperlinks

    Hi this has probably been covered before but is there ideally, a macro or failing that VBA that could be posted as a macro, that will test a spreadsheet with well over 500 hyperlinks on it for links that fail but need to indicate when a link fails

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Hyperlinks

    This sounds like an interesting problem. My VBA is VERY weak, but buy posting here, I will get you back to the top of the lis, so others can see it.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Hyperlinks

    Sure, you'd send request via winhttp and check returned status.

    Assuming hyperlinks are all stored in cell(s) and that the column next to it is where status will be recorded.

    Function to test link
    Function TestLink(url As String) As Boolean
        Dim mylink As Hyperlink
        On Error GoTo ErrHandle:
            With CreateObject("WinHttp.WinHttpRequest.5.1")
                .Open "HEAD", url
                .Send
                If .Status = 200 Then
                    res = True
                Else
                    res = False
                End If
            End With
            TestLink = res
            Exit Function
    ErrHandle:
            TestLink = False
    End Function
    You can use it like...
    Sub Demo()
    Dim mylink As Hyperlink
    
    For Each mylink In Worksheets(1).Hyperlinks
        mylink.Range.Offset(, 1).Value = TestLink(mylink.Address)
    Next
    End Sub
    Result:
    0.JPG

    Note: Since I originally intended to check in code, result is set to Boolean. You can set it to String and change True to "Good", False to "Bad" if you like.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  4. #4
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Hyperlinks

    Are the hyperlinks to web sites, external files on a file system (local or network share) or are they links to internal content (like other cells)?

    Testing the above, off the top of my head, would work differently depending on what you need to check.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Hyperlinks

    Oh, right I assumed sites. If files you’ll need to use dir() function, for link to cell, you’d check if it is a valid object.

+ 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. Hyperlinks - change sheet but not cell reference for multiple hyperlinks at once
    By matt1x1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-19-2018, 05:58 AM
  2. [SOLVED] Range containing many hyperlinks is default blue font -fix to be black but keep hyperlinks
    By RedSummer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2015, 12:01 PM
  3. Excel Hyperlinks in Powerpoint Error - Hyperlinks stripped
    By memsimpson in forum Excel General
    Replies: 1
    Last Post: 05-27-2014, 01:55 PM
  4. Excel Hyperlinks in Powerpoint Error - Hyperlinks stripped
    By memsimpson in forum Excel General
    Replies: 0
    Last Post: 05-27-2014, 09:25 AM
  5. Find Hyperlinks, Copy Hyperlinks to alternative sheet, print all hyperlinks
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2013, 05:13 PM
  6. Replies: 7
    Last Post: 06-14-2012, 09:44 AM
  7. Replies: 0
    Last Post: 05-14-2006, 11:45 PM

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