#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default File Exists

Using 2003 - I need to know if a file exists in a selected folder.
When I looked up the FileExists function in the online help I found the
following:
Description

Returns True if a specified file exists; False if it does not.

Syntax

object.FileExists(filespec)

The FileExists method syntax has these parts:

Part Description
object Required. Always the name of a FileSystemObject.
filespec Required. The name of the file whose existence is to be
determined. A complete path specification (either absolute or relative)
must be provided if the file isn't expected to exist in the current
folder.

That doesn't tell me anything I can understand. There isn't any
example.

Let's say the file I need to know about is "ABC.txt" and the folder I
will query is C:\MyFolder. What is the code I need to write that will
tell me if the file exists or not?

Glen

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default File Exists

You can use Dir Glen

If Dir("C:\MyFolder\ABC.txt") < "" Then





--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message oups.com...
Using 2003 - I need to know if a file exists in a selected folder.
When I looked up the FileExists function in the online help I found the
following:
Description

Returns True if a specified file exists; False if it does not.

Syntax

object.FileExists(filespec)

The FileExists method syntax has these parts:

Part Description
object Required. Always the name of a FileSystemObject.
filespec Required. The name of the file whose existence is to be
determined. A complete path specification (either absolute or relative)
must be provided if the file isn't expected to exist in the current
folder.

That doesn't tell me anything I can understand. There isn't any
example.

Let's say the file I need to know about is "ABC.txt" and the folder I
will query is C:\MyFolder. What is the code I need to write that will
tell me if the file exists or not?

Glen

  #3   Report Post  
Posted to microsoft.public.excel.programming
zz zz is offline
external usenet poster
 
Posts: 14
Default File Exists

"dir" function is also helpful

if dir("file.txt") then
do_something
else
do_something_else
endif


wrote in message
oups.com...
Using 2003 - I need to know if a file exists in a selected folder.
When I looked up the FileExists function in the online help I found the
following:
Description

Returns True if a specified file exists; False if it does not.

Syntax

object.FileExists(filespec)

The FileExists method syntax has these parts:

Part Description
object Required. Always the name of a FileSystemObject.
filespec Required. The name of the file whose existence is to be
determined. A complete path specification (either absolute or relative)
must be provided if the file isn't expected to exist in the current
folder.

That doesn't tell me anything I can understand. There isn't any
example.

Let's say the file I need to know about is "ABC.txt" and the folder I
will query is C:\MyFolder. What is the code I need to write that will
tell me if the file exists or not?

Glen



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
If a file exists then do this... hshayh0rn Excel Programming 1 April 18th 06 09:29 PM
File Exists Pflugs Excel Programming 2 September 4th 05 07:05 AM
IF File Exists [email protected] Excel Programming 1 November 22nd 04 07:24 PM
File already exists Michael Malinsky[_3_] Excel Programming 0 June 28th 04 08:02 PM
the file already exists - do you want to replace the existing file? Paul James[_3_] Excel Programming 4 December 12th 03 02:50 AM


All times are GMT +1. The time now is 05:41 AM.

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

About Us

"It's about Microsoft Excel"