Results 1 to 7 of 7

Automatically Test Hyperlinks in Excel 2007

Threaded View

  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    8

    Automatically Test Hyperlinks in Excel 2007

    I have generated this as a new thread with the same title, as, apparently, I have not met the forum guidelines in the previous thread.
    I am looking for a way to check all the hyperlinks within a workbook. I have several files containing hundreds of hyperlinks to networked files. As the network is accessed by many people, and there are no protocols controlling the movement, I find some of the hyperlinks no longer work because the files are no longer in the hyperlinked location.

    In the previous thread the following was posted:

    sub snb()
      on error resume next
      for each hp in sheets(1).hyperlinks
        thisworkbook.followhyperlink hp.address
        if err.number<>0 then hp.Range.Interior.ColorIndex = 3
        err.clear
      next
    end sub
    This works fine but opens each hyperlink in turn, meaning the PC grinds to a halt through lack of resources.
    To overcome this issue the following was posted:

    Sub snb()
     On Error Resume Next
    
     With New XMLHTTPRequest
      For Each hp In Sheets(1).Hyperlinks
       .Open "get", hp.Address
       .send
       If Err.Number <> 0 Then hp.Range.Interior.ColorIndex = 3
       Err.Clear
      Next
     End With
    End Sub
    This overcomes the problem of opening each hyperlink, but gives an error error code value of '-2147467259' for all files, meaning each hyperlink cell turns red. Note the same files do not show an error in the first code.
    I have tried adding a 10 second delay after the '.send' line in case the error is caused by a process timeout, as the files are on our (slow) network. The delay works but the error still exists. The 'Err.Clear' is changing the value to '0' as expected, so the error must be generated within the code.
    Does anyone know where I can find out what the error value relates to and better still, how to eradicate it.
    How can I modify this code so I do not get an error for each hyperlink?
    Last edited by Cutter; 08-01-2012 at 08:51 AM. Reason: Added code tags

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