+ Reply to Thread
Results 1 to 3 of 3

File Exists

  1. #1
    Pflugs
    Guest

    File Exists

    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

  2. #2
    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 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

  3. #3
    William Benson
    Guest

    Re: File Exists

    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

    "Pflugs" <[email protected]> wrote in message
    news:[email protected]...
    >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




+ 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