How can i deletete excel file saved as "D:\PRLIST.xls" through VB Code.

Recommended Answers

All 3 Replies

Hi,

You can delete any file from the disk using the KILL command

Syntax:
KILL <filename with path>

Before deleting any file you can check if it exists in the path or not first.

If Dir("D:\PRLIST.XLS", vbNormal) <> "" Then
        If MsgBox("DELETE FILE?", vbYesNo + vbInformation, "DELETION") = vbYes Then
            Kill "D:\PRLIST.XLS"
        End If
    Else
        MsgBox "No Such File Exists."
    End If

Regards
Shaik Akthar

You cam also use FileSystemObject.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.