hi,
does someone have a vbscript to check for file existance in a virtual
path ?
eg. http://www.yourserver.com/someDirectory/file.doc


pls help. thanks

Re: virtual path by Scripty

Scripty
Fri Feb 18 06:42:14 CST 2005

Hi , you should be able to do this using the ADO stream object?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthopenstream.asp

snippet:

Stream.Open Source, Mode, OpenOptions, UserName, Password

Parameters
Source
Optional. A Variant value that specifies the source of data for the
Stream. Source may contain an absolute URL string that points to an
existing node in a well-known tree structure, like an e-mail or file
system. A URL should be specified using the URL keyword
("URL=scheme://server/folder"). Alternately, Source may contain a
reference to an already open Record object, which opens the default
stream associated with the Record. If Source is not specified, a Stream
is instantiated and opened, associated with no underlying source by
default


Re: virtual path by Lynn

Lynn
Fri Feb 18 08:40:24 CST 2005

how can i put this in a winword macro?

"Scripty" <isdeveloper@hotmail.com> wrote in message
news:1108730534.208310.254710@g14g2000cwa.googlegroups.com...
> Hi , you should be able to do this using the ADO stream object?
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthopenstream.asp
>
> snippet:
>
> Stream.Open Source, Mode, OpenOptions, UserName, Password
>
> Parameters
> Source
> Optional. A Variant value that specifies the source of data for the
> Stream. Source may contain an absolute URL string that points to an
> existing node in a well-known tree structure, like an e-mail or file
> system. A URL should be specified using the URL keyword
> ("URL=scheme://server/folder"). Alternately, Source may contain a
> reference to an already open Record object, which opens the default
> stream associated with the Record. If Source is not specified, a Stream
> is instantiated and opened, associated with no underlying source by
> default
>



Re: virtual path by ljb

ljb
Fri Feb 18 11:29:18 CST 2005


"Lynn" <MarryLynn@yah00.c0m> wrote in message
news:eRsWBhcFFHA.1260@TK2MSFTNGP12.phx.gbl...
> how can i put this in a winword macro?
>
> "Scripty" <isdeveloper@hotmail.com> wrote in message
> news:1108730534.208310.254710@g14g2000cwa.googlegroups.com...
> > Hi , you should be able to do this using the ADO stream object?
> >
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthopenstream.asp
> >
> > snippet:
> >
> > Stream.Open Source, Mode, OpenOptions, UserName, Password
> >
> > Parameters
> > Source
> > Optional. A Variant value that specifies the source of data for the
> > Stream. Source may contain an absolute URL string that points to an
> > existing node in a well-known tree structure, like an e-mail or file
> > system. A URL should be specified using the URL keyword
> > ("URL=scheme://server/folder"). Alternately, Source may contain a
> > reference to an already open Record object, which opens the default
> > stream associated with the Record. If Source is not specified, a Stream
> > is instantiated and opened, associated with no underlying source by
> > default
> >
>
>

url = http://...com/..../...html
Set xmldoc = CreateObject("Msxml2.DOMDocument.4.0")
xmldoc.async = False
If xmldoc.Load(url) Then
'do something because file exists
else
'file does not exist
end if



Re: virtual path by Lynn

Lynn
Fri Feb 18 23:37:14 CST 2005

ljb,
i used your code and found that regardless of whether the file exists
or does not exists. the result is always "not found"
any clues?


Re: virtual path by Roland

Roland
Sat Feb 19 13:42:23 CST 2005

"Lynn" wrote in message
news:1108791434.769498.176830@g14g2000cwa.googlegroups.com...
: i used your code and found that regardless of whether the file exists
: or does not exists. the result is always "not found"
: any clues?

WSH version:

Option Explicit

function checkURL(file)
Dim oHTTP, status
set oHTTP = CreateObject("MSXML2.ServerXMLHTTP")
oHTTP.open "GET", file, False
oHTTP.send
status = oHTTP.Status
if status = 200 then
checkURL = " exists!"
else
checkURL = " does not exists."
end if
set oHTTP = nothing
end function

dim fExists, vFilename
vFilename = "http://www.kiddanger.com/default.asp"
fExists = checkURL(vFilename)
wscript.echo vFilename & fExists

vFilename = "http://www.kiddanger.com/unknownfile.asp"
fExists = checkURL(vFilename)
wscript.echo vFilename & fExists

ASP version:
http://kiddanger.com/lab/geturl5.asp

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: virtual path by Michael

Michael
Sat Feb 19 15:10:27 CST 2005

> WSH version:
>
> Option Explicit
>
> function checkURL(file)
> Dim oHTTP, status
> set oHTTP = CreateObject("MSXML2.ServerXMLHTTP")
> oHTTP.open "GET", file, False

If all you want to do is verify existence, it's cheaper to do a HEAD request
rather than a GET which returns content that is not used by the client...

oHTTP.open "HEAD", file, False

This returns the same status code, etc. but no responseBody or responseText,
only the http headers (access using oHTTP.getAllResponseHeaders() or
getResponseHeader(bstrHeader)).


> oHTTP.send
> status = oHTTP.Status
> if status = 200 then
> checkURL = " exists!"
> else
> checkURL = " does not exists."
> end if
> set oHTTP = nothing
> end function
>
> dim fExists, vFilename
> vFilename = "http://www.kiddanger.com/default.asp"
> fExists = checkURL(vFilename)
> wscript.echo vFilename & fExists
>
> vFilename = "http://www.kiddanger.com/unknownfile.asp"
> fExists = checkURL(vFilename)
> wscript.echo vFilename & fExists
>
> ASP version:
> http://kiddanger.com/lab/geturl5.asp

--
Michael Harris
Microsoft MVP Scripting
http://maps.google.com/maps?q=Sammamish%20WA%20US



Re: virtual path by Lynn

Lynn
Sat Feb 19 23:08:44 CST 2005

i am totally new to this xml stuffs..
can i know how to fit this code into an office macro?

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:%23hQridsFFHA.2832@TK2MSFTNGP14.phx.gbl...
> > WSH version:
> >
> > Option Explicit
> >
> > function checkURL(file)
> > Dim oHTTP, status
> > set oHTTP = CreateObject("MSXML2.ServerXMLHTTP")
> > oHTTP.open "GET", file, False
>
> If all you want to do is verify existence, it's cheaper to do a HEAD
request
> rather than a GET which returns content that is not used by the client...
>
> oHTTP.open "HEAD", file, False
>
> This returns the same status code, etc. but no responseBody or
responseText,
> only the http headers (access using oHTTP.getAllResponseHeaders() or
> getResponseHeader(bstrHeader)).
>
>
> > oHTTP.send
> > status = oHTTP.Status
> > if status = 200 then
> > checkURL = " exists!"
> > else
> > checkURL = " does not exists."
> > end if
> > set oHTTP = nothing
> > end function
> >
> > dim fExists, vFilename
> > vFilename = "http://www.kiddanger.com/default.asp"
> > fExists = checkURL(vFilename)
> > wscript.echo vFilename & fExists
> >
> > vFilename = "http://www.kiddanger.com/unknownfile.asp"
> > fExists = checkURL(vFilename)
> > wscript.echo vFilename & fExists
> >
> > ASP version:
> > http://kiddanger.com/lab/geturl5.asp
>
> --
> Michael Harris
> Microsoft MVP Scripting
> http://maps.google.com/maps?q=Sammamish%20WA%20US
>
>



Re: virtual path by Roland

Roland
Sun Feb 20 04:23:52 CST 2005

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:%23hQridsFFHA.2832@TK2MSFTNGP14.phx.gbl...
:> WSH version:
: >
: > Option Explicit
: >
: > function checkURL(file)
: > Dim oHTTP, status
: > set oHTTP = CreateObject("MSXML2.ServerXMLHTTP")
: > oHTTP.open "GET", file, False
:
: If all you want to do is verify existence, it's cheaper to do a HEAD
request
: rather than a GET which returns content that is not used by the client...
:
: oHTTP.open "HEAD", file, False
:
: This returns the same status code, etc. but no responseBody or
responseText,
: only the http headers (access using oHTTP.getAllResponseHeaders() or
: getResponseHeader(bstrHeader)).

I did a quick search trying to find a way to get it so good to know there is
a better way. I also assumed, probably wrongly, that she wanted content but
not the reason I wrote the script. I just didn't know any better.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: virtual path by Lynn

Lynn
Mon Feb 21 21:15:25 CST 2005

any help?


Re: virtual path by Roland

Roland
Tue Feb 22 00:09:27 CST 2005

"Lynn" <moley_cruz@yahoo.com.au> wrote in message
news:1109042125.105374.292960@c13g2000cwb.googlegroups.com...
: any help?

I'm office macro challenged. Perhaps taking the code you got here to an
office NG might help unless someone else wants to take a stab at it.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: virtual path by Lynn

Lynn
Tue Feb 22 00:56:02 CST 2005

i am totally new to this xml stuffs..
can i know how to fit this code into an office macro?