在Excel中检查破损的超链接

我有一大串超链接(加上一些废话),我需要检查。 我需要知道哪些链接仍处于活动状态,哪些链接不再存在或返回404(或其他)错误。 我一直在使用这个项目中的build议: 在Excel中用VBAsorting无效的超链接? 而且它在一小段链接上运行得很好,其中一些我故意破坏自己。 不过,现在我尝试使用我的超链接的实际列表中的相同的macros,它将不会工作! 我已经手动检查了一些,并发现404错误的链接。 再次,当我故意错误地input一个地址时,它会select这个地址,但是它不会在列表中find已经被破坏的地址。

我对macros来说是全新的,在这里黑暗中真的很磕磕绊绊。 任何帮助/build议将非常感激!

我一直在使用这一段时间,它一直在为我工作。

Sub Audit_WorkSheet_For_Broken_Links() If MsgBox("Is the Active Sheet a Sheet with Hyperlinks You Would Like to Check?", vbOKCancel) = vbCancel Then Exit Sub End If On Error Resume Next For Each alink In Cells.Hyperlinks strURL = alink.Address If Left(strURL, 4) <> "http" Then strURL = ThisWorkbook.BuiltinDocumentProperties("Hyperlink Base") & strURL End If Application.StatusBar = "Testing Link: " & strURL Set objhttp = CreateObject("MSXML2.XMLHTTP") objhttp.Open "HEAD", strURL, False objhttp.Send If objhttp.statustext <> "OK" Then alink.Parent.Interior.Color = 255 End If Next alink Application.StatusBar = False On Error GoTo 0 MsgBox ("Checking Complete!" & vbCrLf & vbCrLf & "Cells With Broken or Suspect Links are Highlighted in RED.") End Sub 

指定一个实际地址代替alink,或者将alink定义为一个包含Web地址的variables。

缺lessvariables定义,下面的工作代码的URL

 Dim alink As Hyperlink Dim strURL As String Dim objhttp As Object 

大容量URL检查macrosmacros