Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if file exists

Status
Not open for further replies.

Lagoon1

IS-IT--Management
Dec 27, 2003
46
AU
Hi
I have set up a listing of file names on, say Sheet 1.
I would like a code that loops through the folder and returns "file found" or "file not found."

I have already set the filter for the type of files that I need.

Can someone pls kindly assist.

Thanks very much.

Regards,

Lagoon1.
 
something like this perhaps?

If Dir("C:\Folder\Filename") > "" Then
Range("A1")="Found"
Else
Range("A1")="NotFound"
EndIf
 
hi Lagoon.

You could try with the "FileExists" method:

Dim fs, fe as boolean
Set fs = CreateObject("Scripting.FileSystemObject")
fe=fs.FileExists(filepath)

if fe then
Range("A1")="Found"
else
Range("A1")="NotFound"
endif

Cheers,
MakeitSo



Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top