Created
July 5, 2013 20:17
-
-
Save brazilnut2000/5936974 to your computer and use it in GitHub Desktop.
VBA: Check to see if a given path or file exist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' Code based on snippet from John Walkenbach | |
| Function FileExists(fileName) As Boolean | |
| FileExists = Dir(fileName) <> "" | |
| End Function | |
| Function PathExists(pathName) As Boolean | |
| ' Returns TRUE if the path exists | |
| On Error Resume Next | |
| PathExists = (GetAttr(pathName) And vbDirectory) = vbDirectory | |
| End Function | |
| Sub CreateFolderIfNeeded(pathName) | |
| If PathExists(pathName) = False Then MkDir (pathName) | |
| End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment