PC Review


Reply
Thread Tools Rate Thread

Detecting Internet Site

 
 
J Streger
Guest
Posts: n/a
 
      12th Jan 2009
I am writing code to go out to a sharepoint and grab files from the
sharepoint. I have encountered lots of issues as my workplace doesn't have
that handy .ocx library that has the ability to detect if files exist on the
internet. I cannot install 3rd party applications or use anything that isn't
in the general system ghost.

So I was hoping there would be a Windows API call that could detect if a
file/website exists. Currently I have the following (which I grabbed
partially from another site). It detects if a file exists at a website, but
if the website doesn't exist it just creates the file and returns 1 saying
the file exists:

Public Function InternetFileExists(sPath As String) As Long

Dim HTML As HTMLDocument
Dim tHTML As HTMLDocument
Dim lRet As Long

On Error GoTo CATCHERROR

'Create new HTML Doc
Set tHTML = New HTMLDocument

'Create a document from the URL Path
Set HTML = tHTML.createDocumentFromUrl(sPath, vbNullString)

'wait for the document to load
Do While HTML.readyState <> "complete"
DoEvents
Loop

'Test to see if a 404 or similar error is found
If InStr(1, LCase(HTML.body.innerText), "not found") > 0 Then
lRet = 0
Else
lRet = 1
End If

QUICKEXIT:

InternetFileExists = lRet

'Clear Variables
Set HTML = Nothing
Set tHTML = Nothing

Exit Function

CATCHERROR:

lRet = -1
Resume QUICKEXIT

End Function 'InternetFileExists

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003

 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      13th Jan 2009
http://www.tech-archive.net/Archive/.../msg00560.html

Function Fetch(xURL)
On Error Resume Next
Err.Clear
Dim objXML
Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "HEAD",xURL,False
objXML.Send
If Err.Number <> 0 Then
Fetch = "Error# " & Err.Number
Else
Fetch = "Status " & objXML.Status
End If
Fetch = Fetch & " : " & xURL
Set objXML = Nothing
End Function

Tim

"J Streger" <(E-Mail Removed)> wrote in message
news:99224BBC-B380-4155-94FB-(E-Mail Removed)...
>I am writing code to go out to a sharepoint and grab files from the
> sharepoint. I have encountered lots of issues as my workplace doesn't have
> that handy .ocx library that has the ability to detect if files exist on
> the
> internet. I cannot install 3rd party applications or use anything that
> isn't
> in the general system ghost.
>
> So I was hoping there would be a Windows API call that could detect if a
> file/website exists. Currently I have the following (which I grabbed
> partially from another site). It detects if a file exists at a website,
> but
> if the website doesn't exist it just creates the file and returns 1 saying
> the file exists:
>
> Public Function InternetFileExists(sPath As String) As Long
>
> Dim HTML As HTMLDocument
> Dim tHTML As HTMLDocument
> Dim lRet As Long
>
> On Error GoTo CATCHERROR
>
> 'Create new HTML Doc
> Set tHTML = New HTMLDocument
>
> 'Create a document from the URL Path
> Set HTML = tHTML.createDocumentFromUrl(sPath, vbNullString)
>
> 'wait for the document to load
> Do While HTML.readyState <> "complete"
> DoEvents
> Loop
>
> 'Test to see if a 404 or similar error is found
> If InStr(1, LCase(HTML.body.innerText), "not found") > 0 Then
> lRet = 0
> Else
> lRet = 1
> End If
>
> QUICKEXIT:
>
> InternetFileExists = lRet
>
> 'Clear Variables
> Set HTML = Nothing
> Set tHTML = Nothing
>
> Exit Function
>
> CATCHERROR:
>
> lRet = -1
> Resume QUICKEXIT
>
> End Function 'InternetFileExists
>
> --
> *********************
> J Streger
> MS Office Master 2000 ed.
> MS Project White Belt 2003
>
> User of MS Office 2003
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with site-to-site connection between branch office and internet server .... Daniel Microsoft Windows 2000 RAS Routing 0 1st Dec 2006 05:25 AM
Detecting Internet Connection SouthSpawn Microsoft Dot NET Framework Forms 1 11th Nov 2004 02:54 PM
Detecting Internet con =?Utf-8?B?S2Vu?= Microsoft ASP .NET 0 16th Oct 2004 08:17 PM
Internet Explorer was nolt able to open this Internet site. The requesed site is either unavailable or cannot be found. Ron Boetger Windows XP Internet Explorer 0 13th Jun 2004 11:46 PM
IE 6 sp1 unable to open internet site or site cannot be found =?Utf-8?B?Z2Vvcmdl?= Windows XP Internet Explorer 1 16th Feb 2004 10:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:44 AM.