But at this point I have another question:
if the string expression does not contain a valid url then how can we trap
this error programatically?
If you want to check the URL for syntactic validity, but not whether the URL
actually exists on the network, you can use a function like the following.
This will return TRUE if the URL is properly formed but does not test
whether it is an existing, accessible, location.
Function IsValidURL(URL As String) As Boolean
Dim RegExp As Object
Dim S As String
If StrComp(Left(URL, 4), "http", vbTextCompare) <> 0 Then
S = "http://" & URL
Else
S = URL
End If
Set RegExp = CreateObject("vbscript.regexp")
RegExp.Pattern =
"^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}

[a-zA-Z0-9]*)" & _
"?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*[^\.\,\)\(\s]$"
IsValidURL = RegExp.test(S)
End Function
--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)