Consulting

Results 1 to 4 of 4

Thread: Solved: Test if Folder Exists

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Solved: Test if Folder Exists

    How do I test if a Folder exists? I use a persons excel username in excel to find their folder on our servers but sometimes people have incorrect usernames in Excel. I would like to test their username next to all the folders on the H drive and if that name does not exist I want to do a popup asking telling people to correct their username. I know how to do all of it except testing if a folder exists with that name.
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

  2. #2
    VBAX Mentor
    Joined
    Jun 2004
    Posts
    363
    Location
    Something like this perhaps:
    [vba]
    Sub DirctoryTest()
    If Dir("H:\MyDirectory\", vbDirectory) = "" Then
    MsgBox "Directory Does Not Exist"
    Exit Sub
    Else
    MsgBox "Directory is Valid"
    'Do Other Stuff
    End If
    End Sub

    [/vba]

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    That works perfectly.
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

  4. #4
    Nicely done!

Posting Permissions

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