File Exists Formula

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a formula that can ba used in a cell to check if a file exists; if
the file does exists then do .......

In other languages I've used : If fexists(filename) then .....
 
I think I've used something like this before.


If Len(Dir([path and Filename])) _
Then
msgbox ("File already exists!")
end
Else:
<Your code>
end if


HTH,
Paul
 
One note, the pathname should be in quotes unless it will be referenced by a
cell reference or variable.

HTH,
Paul

PCLIVE said:
I think I've used something like this before.


If Len(Dir([path and Filename])) _
Then
msgbox ("File already exists!")
end
Else:
<Your code>
end if


HTH,
Paul


El Bee said:
Is there a formula that can ba used in a cell to check if a file exists;
if
the file does exists then do .......

In other languages I've used : If fexists(filename) then .....
 
Paul,

I'm struggling with the syntax.
I have file on Drive L
In the directory called TechnicalServices
Sub directory called "Daily Status Reports" (space between each word)
File name is MyFile110608.xls.

I have tried your syntax and keep getting an error; "That name is invalid"

here' the text of the formula:

=IF LEN(DIR([\\L:\depts\TechnicalServices\Daily Status Report\History\IT
Daily Status 061108.xls]))

I have tried including quotes but I get the same error; where am I going
wrong?

Thanks for your time and help.

Larry

PCLIVE said:
I think I've used something like this before.


If Len(Dir([path and Filename])) _
Then
msgbox ("File already exists!")
end
Else:
<Your code>
end if


HTH,
Paul


El Bee said:
Is there a formula that can ba used in a cell to check if a file exists;
if
the file does exists then do .......

In other languages I've used : If fexists(filename) then .....
 
Sorry Larry,

I overlooked the fact that you posted this in worksheet functions. The
solution I gave you would be used in a Macro (Visual Basic). I'm not
exactly sure how to do it in a function.
Maybe something like:

=IF(ISERROR('L:\depts\TechnicalServices\Daily Status Report\History\[IT
Daily Status 061108.xls]Sheet1'!$A$1)=TRUE,"File does not exist!","File
already exists!")

There may be another way to better suit your needs, but that's all I could
come up with right now.

HTH,
Paul


El Bee said:
Paul,

I'm struggling with the syntax.
I have file on Drive L
In the directory called TechnicalServices
Sub directory called "Daily Status Reports" (space between each word)
File name is MyFile110608.xls.

I have tried your syntax and keep getting an error; "That name is invalid"

here' the text of the formula:

=IF LEN(DIR([\\L:\depts\TechnicalServices\Daily Status Report\History\IT
Daily Status 061108.xls]))

I have tried including quotes but I get the same error; where am I going
wrong?

Thanks for your time and help.

Larry

PCLIVE said:
I think I've used something like this before.


If Len(Dir([path and Filename])) _
Then
msgbox ("File already exists!")
end
Else:
<Your code>
end if


HTH,
Paul


El Bee said:
Is there a formula that can ba used in a cell to check if a file
exists;
if
the file does exists then do .......

In other languages I've used : If fexists(filename) then .....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top