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
- 2769 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