URL validation module problem

lelek

New Member
Joined
Dec 1, 2018
Messages
2
Hello,

I have a function to validate URLs. It return as result "200" if the URL is valid and "404" if the URL is invalid. It works fine with simple URLs like: http://www.mywebsite.com/products/dresses/blue-dress

But it not work properly with URLs which contain anchors (#). For this kind of URLs the function returns also "404" as result although the URLs are working/good URLs. An example of this kind of URL: http://mywebsite.com/en/women/dresses/59983-lovydress_1#/237-color-maroon/117-size-40 This is a prestashop URL which contain color and size variation.

I use Excel 2003 and unfortunately I can't upgrade Excel because I work not on my PC and I have no permision for upgrade.

I send bellow my function, have somebody a solution ?

Code:
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
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
What happens if you ELIMINATE all the "error handling code lines" and in place of the line On Error Goto haveError - use On Error Resume Next?
 
Last edited:
Upvote 0
Hello,

Thank you for your replay. Not workink if I eliminate the error handling code lines and if I replace with On Error Resume Next. I got an error message in excel. BUT maybe I rewrited wrong the function ...!!!

I think I must use the following:
WINHTTP_OPTION_URL ... but I don't know how to use it !!!
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,205
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top