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
- 2834 reads
Recent comments
5 years 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago