I feel obliged to preface this by stressing not a Visual Basic expert. Indeed, my grasp of Visual Basic is rudimentary at best.
That said, I have an Excel file with a single column containing a series of URL addresses. Next to that column I've created an additional column "Link Check", wherein I would like to dynamically return the HTTP status of each URL address.
I've attempted to create a simple function using Visual Basic that will do just that. Here is that function as currently written:
Public Function CheckURL(url As String)
Dim request As Object
Set request = CreateObject("WinHttp.WinHttpRequest.5.1")
On Error GoTo haveError
With request
.Open "HEAD", url
.Send
CheckURL = .Status
End With
Exit Function
haveError:
CheckURL = Err.Description
End Function
As written, any attempt to utilize this function returns a #VALUE!
error.
Anyone have any suggestions as to how I might change the code to produce a workable result?