Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Test is cell contents are a URL

Is there a quick and easy way to test if the contents of a cell (it's
text, not a hyperlink object) are a valid URL? I'm wondering about any
functionality and not just looking for the http or some other text to
parse out.

TIA,
Jim

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Test is cell contents are a URL

Hi Jim,

Jim wrote:
Is there a quick and easy way to test if the contents of a cell (it's
text, not a hyperlink object) are a valid URL? I'm wondering about
any functionality and not just looking for the http or some other
text to parse out.


You could try something like this, which can be called from VBA or as a
user-defined worksheet function. I haven't tested it much, but it seems to
work OK.

Public Function IsValidURL(rsURL As String) As Variant
Dim x As Object

On Error GoTo ErrHandler

Set x = CreateObject("Microsoft.XMLHTTP")
x.Open "GET", rsURL
x.send
Do Until x.readyState = 4
DoEvents
Loop
IsValidURL = (x.Status < 404)

ExitRoutine:
Set x = Nothing
Exit Function
ErrHandler:
Select Case Err.Number
Case 429
IsValidURL = "XML lib not installed."
Case Else
IsValidURL = False
End Select
Resume ExitRoutine
End Function

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
concatenate contents of cells whose contents resemble cell referem cathyh Excel Worksheet Functions 3 May 23rd 09 12:16 PM
Is there a logical test for a cell's format instead of contents Bruce Excel Worksheet Functions 3 November 17th 05 01:40 AM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
Cell contents vs. Formula contents Sarah Excel Discussion (Misc queries) 3 December 15th 04 06:02 PM
Copying cell contents to add to existing contents in another cell Dean Sawas Excel Programming 3 April 2nd 04 09:00 PM


All times are GMT +1. The time now is 10:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"