首页 > 解决方案 > 用于了解 URL 有效性的 VBA 代码将检查 URL 是否存在

问题描述

我有知道 URL 存在的代码,但在许多其他系统或其他办公版本中它不起作用。可以帮我吗?我在哪里做错了?有替代选择吗?在此先感谢我正在使用代码来知道 URL VALIDITY 是

Public Function IsURLGood(URL As String) As Boolean
Dim request As New WinHttpRequest

On Error GoTo IsURLGoodError
request.Open "HEAD", URL
request.send
If request.Status = 200 Then
    IsURLGood = True
Else
    IsURLGood = False
End If
Exit Function

IsURLGoodError:
IsURLGood = False
End Function

检查 URL 是否存在

If IsURLGood(Sheet1.Range("D10")) Then
'MsgBox "correct"
Else
MsgBox "URL is invalid."
    End If

标签: excelvbaurl

解决方案


推荐阅读