Freshman
Registered User.
- Local time
- Today, 16:52
- Joined
- May 21, 2010
- Messages
- 437
Hi all,
I found and modified this code to allow me to check (fast) if a file exist on a http server or not (without downloading it).
In the above code I managed to declare Webfile as a string so I can call on it later but one thing I still need to tweak is to also get a result out of the test code in a better way than having to publically declare the "CheckNet" variable somewhere else in my app.
First prize would something like this:
If CheckNetFile ("http://www.mysite.co.za/test/test.txt") = 1 then "Yes" else "No"
How do I build the 'booleon check' into the original function?
Thanks
Pierre
I found and modified this code to allow me to check (fast) if a file exist on a http server or not (without downloading it).
Code:
Public Function CheckNetFile(WebFile As String)
Dim XmlHttpReq As Object
Set XmlHttpReq = CreateObject("Microsoft.XMLHTTP")
XmlHttpReq.Open "HEAD", WebFile, False
XmlHttpReq.Send
If XmlHttpReq.Status = 200 Then CheckNet = 1 Else CheckNet = 0
Set XmlHttpReq = Nothing
End Function
Public Function Test()
CheckNetFile ("[URL]http://www.mysite.co.za/test/test.txt[/URL]")
MsgBox CheckNet
End Function
In the above code I managed to declare Webfile as a string so I can call on it later but one thing I still need to tweak is to also get a result out of the test code in a better way than having to publically declare the "CheckNet" variable somewhere else in my app.
First prize would something like this:
If CheckNetFile ("http://www.mysite.co.za/test/test.txt") = 1 then "Yes" else "No"
How do I build the 'booleon check' into the original function?
Thanks
Pierre