![]() |
Does File Exist
Im after a small piece of code that will check a directory for a certai file and advise whether it exiss or not. Thank you in advance for anyhelp you can provide -- ceem ----------------------------------------------------------------------- ceemo's Profile: http://www.excelforum.com/member.php...fo&userid=1065 View this thread: http://www.excelforum.com/showthread.php?threadid=39949 |
Does File Exist
Code ------------------- if Not Dir("C:\DATA\YOURFILE.XLS") then 'the bugger isnot there! end i ------------------- Dir returns an empty string if no file is found matching the 'search pattern -- Dnere ----------------------------------------------------------------------- Dnereb's Profile: http://www.excelforum.com/member.php...fo&userid=2618 View this thread: http://www.excelforum.com/showthread.php?threadid=39949 |
Does File Exist
Good afternoon ceemo The example below will check whether your C:\ drive contains a fil called filename.xls. In the unlikely event that it does, "TRUE" wil be returned in a msgbox, otherwise (and probably) "FALSE" will b returned. Sub DoesFileExist() Set MyFile = CreateObject("Scripting.FileSystemObject") MsgBox MyFile.FileExists("c:\filename.xls") End Sub HTH Dominic -- dominic ----------------------------------------------------------------------- dominicb's Profile: http://www.excelforum.com/member.php...fo&userid=1893 View this thread: http://www.excelforum.com/showthread.php?threadid=39949 |
All times are GMT +1. The time now is 05:02 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com