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
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
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
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
You can use it like...![]()
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
Result:![]()
Sub Demo() Dim mylink As Hyperlink For Each mylink In Worksheets(1).Hyperlinks mylink.Range.Offset(, 1).Value = TestLink(mylink.Address) Next End Sub
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
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
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks