LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Detecting Internet Site

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

 
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
Mon 1er message sur ce site internet faisant suite à des béné excavationfondations Excel Discussion (Misc queries) 0 September 2nd 10 11:18 PM
Importing Soccer results from Internet Site Jobber Excel Programming 4 August 9th 07 02:46 PM
Detecting Change in State of Internet Explorer Ash Excel Programming 9 October 9th 06 02:28 AM
internet explorer not able to open site Shelly Excel Discussion (Misc queries) 1 March 31st 06 01:44 AM
Download a CSV file from an internet site Microchip Excel Programming 0 March 28th 06 12:41 PM


All times are GMT +1. The time now is 11:36 PM.

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

About Us

"It's about Microsoft Excel"