Option Explicit
Private Sub Command1_Click()
Dim FileSystem
Dim file
Dim fileName
Dim result
'On Error GoTo errorhandler:
CommonDialog1.CancelError = True
CommonDialog1.DialogTitle = "Delete a File"
CommonDialog1.ShowOpen
fileName = CommonDialog1.fileName
result = MsgBox("Are You Sure you want to delete" _
& CommonDialog1.fileName & "?", vbYesNo)
If result = vbYes Then
Set FileSystem = _
CreateObject("Scripting.filesystemobject")
Set file = FileSystem.getfile(fileName)
file.Delete True
End If
'errorhandler:
End Sub
Private Sub Form_Load()
End Sub