XLA routines: EE_DeleteFile

EE_DeleteFile deletes a file if it exists.
Sub EE_DeleteFile(strFilePath As String, Optional blnShowMsg As Boolean = False) '- takes file path '- deletes file '- does not error if file does not exist '- does error if file is locked 'http://excelexperts.com/xla-routines-eeDeleteFile for updates on this sub routine With CreateObject("Scripting.FileSystemObject") If .FileExists(strFilePath) Then On Error Resume Next .deletefile strFilePath If Err.Number <> 0 And blnShowMsg = True Then MsgBox Err.Description, vbCritical, "File locked" End If On Error GoTo 0 End If End With End Sub
»
- Nick's blog
- Login or register to post comments
- 2826 reads
Recent comments
5 years 50 weeks ago
6 years 36 weeks ago
6 years 47 weeks ago
6 years 50 weeks ago
6 years 51 weeks ago
7 years 5 weeks ago
7 years 13 weeks ago
7 years 13 weeks ago
7 years 13 weeks ago
7 years 13 weeks ago