File Exists

P

Pflugs

I am having a macro search for a file on the desktop under "C:\Documents and
Settings\All Users\Desktop\" using "result = Object.FileExists(file_name)".
I know the file exists, but the result is always false. Is there something
wrong with FileExists, or should I do something different?

Thanks,

Matthew
 
D

dominicb

Good morning Pflugs

This code will return true or false (displayed in a msgbox) when
checking for a file.

Sub DoesFileExist()
Set MyFile = CreateObject("Scripting.FileSystemObject")
MsgBox MyFile.FileExists("c:\book1.xls")
End Sub

HTH

DominicB
 
W

William Benson

You say you know it exists ... I assume because you see it on your
desktop... Are you sure it is in All Users\Desktop and not rather in your
own UserName\Desktop? They are not the same path, even though files in
either will show on (your) desktop.

Bill
 

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

Top