Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Check if file on intranet exists

I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
without opening it. I've tried using Dir(myPath) but I get an error 52 'Bad
file name or number'. I've also tried using the FileExists method in VB but
I'm not sure how to use it.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Check if file on intranet exists

Maybe this:
http://vbnet.mvps.org/code/fileapi/pathfileexists.htm

NickHK

"mcphc" wrote in message
...
I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
without opening it. I've tried using Dir(myPath) but I get an error 52

'Bad
file name or number'. I've also tried using the FileExists method in VB

but
I'm not sure how to use it.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Check if file on intranet exists

http (hyper-text transfer protocol) is a transfer protocol and cannot be used
to check if a file exists. In some cases you can use File:// when generating
webpages.

the DIR command cannot be used directly to check for a file on internet.
One thing you can do is add a network drive in you window explorer. Go to
explorer and under tools "Map Netwrok drive". Assign a drive letter to
pmnet. Then you can use the drive letter and file name in the DIR command.

"mcphc" wrote:

I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
without opening it. I've tried using Dir(myPath) but I get an error 52 'Bad
file name or number'. I've also tried using the FileExists method in VB but
I'm not sure how to use it.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Check if file on intranet exists

Use xmlhttp and a "HEAD" request:

'***********************
Function HttpExists(sURL As String) As Boolean
Dim oXHTTP As Object
Set oXHTTP = CreateObject("MSXML2.XMLHTTP")
oXHTTP.Open "HEAD", sURL, False
oXHTTP.send
HttpExists = (oXHTTP.Status = 200)
End Function
'***********************

Tim


"mcphc" wrote in message
...
I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
without opening it. I've tried using Dir(myPath) but I get an error 52
'Bad
file name or number'. I've also tried using the FileExists method in VB
but
I'm not sure how to use it.

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Check if file on intranet exists

That's it works perfectly! Thanks a lot.

"Tim Williams" wrote:

Use xmlhttp and a "HEAD" request:

'***********************
Function HttpExists(sURL As String) As Boolean
Dim oXHTTP As Object
Set oXHTTP = CreateObject("MSXML2.XMLHTTP")
oXHTTP.Open "HEAD", sURL, False
oXHTTP.send
HttpExists = (oXHTTP.Status = 200)
End Function
'***********************

Tim


"mcphc" wrote in message
...
I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
without opening it. I've tried using Dir(myPath) but I get an error 52
'Bad
file name or number'. I've also tried using the FileExists method in VB
but
I'm not sure how to use it.

Thanks




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
Check if a File Exists Ray Clark[_2_] Excel Programming 4 June 11th 08 05:13 PM
Check if file exists Jon Excel Discussion (Misc queries) 14 October 4th 07 04:57 PM
How to check if a file exists in an ftp folder LL Cool A Excel Discussion (Misc queries) 3 May 16th 06 09:22 PM
check if file exists Curt Excel Programming 0 December 7th 05 05:02 PM
check if a file exists / is open Mark Kubicki Excel Programming 1 December 4th 03 05:56 PM


All times are GMT +1. The time now is 03:00 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"