+ Reply to Thread
Results 1 to 3 of 3

Does File Exist

  1. #1
    Forum Contributor
    Join Date
    06-15-2004
    Posts
    246

    Does File Exist

    Im after a small piece of code that will check a directory for a certain file and advise whether it exiss or not.

    Thank you in advance for anyhelp you can provide.

  2. #2
    Registered User
    Join Date
    08-11-2005
    Location
    Netherlands Waddinxveen
    Posts
    81
    Please Login or Register  to view this content.
    Dir returns an empty string if no file is found matching the 'search' pattern.

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon ceemo

    The example below will check whether your C:\ drive contains a file called filename.xls. In the unlikely event that it does, "TRUE" will be returned in a msgbox, otherwise (and probably) "FALSE" will be returned.

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

    HTH

    DominicB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1