XLA routines: EE_CheckPaths
EE_CheckPaths takes a range containing file paths, and checks to see if they all exist.
- very useful at the start of a routine that depends on files existing.
- check the paths and exit if they don't exist
Function EE_CheckPaths(rngPaths As range, Optional blnDispMissingMsg As Boolean = True) As Boolean '- takes a range of cells containing file paths / folders. '- checks if they exist '- returns false if any 1 doesn't exist '- displays messagebox with list of missing paths Dim strMissingPaths As String Dim rngEachPath As range 'http://excelexperts.com/xla-routines-eeCheckPaths for updates on this function For Each rngEachPath In rngPaths If rngEachPath.value <> vbNullString Then If Not EE_FileFolderExists(rngEachPath.value) Then strMissingPaths = strMissingPaths & vbLf & rngEachPath.value End If End If Next rngEachPath If strMissingPaths <> "" Then EE_CheckPaths = False If blnDispMissingMsg = True Then MsgBox "Folder/File path(s) not found:" & vbLf & strMissingPaths, vbCritical, "Missing path" End If Else EE_CheckPaths = True End If Set rngEachPath = Nothing End Function
»
- Nick's blog
- Login or register to post comments
- 2807 reads
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago