PDA

View Full Version : Solved: Test if Folder Exists



Djblois
04-19-2010, 10:02 AM
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.

mbarron
04-19-2010, 11:57 AM
Something like this perhaps:

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

Djblois
04-19-2010, 12:26 PM
That works perfectly.

MrNorway
04-10-2011, 08:02 AM
Nicely done!:clap: