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