Tuesday, 2 October 2012

How To Delete All Excel Files From a Desired Directory or Folder

Excel VBA Macro To  Remove  All Excel Files From a Desired Directory or Folder
'Macro To  Remove Any Type of Files From a Desired Directory or Folder
'Let us suppose if you want to delete all excel files loacated in My Documents
'You can use the "KILL" statement and *(Asterisk) with file extension "*.xlsx" to delete all ".xlsx" File Types

!!!!!!---< Cautious....Be aware....Take Care....Before Using Kill Statment >---!!!!!!

Sub KillAllMyXlFiles()
Dim P As String
P = "C:\Documents and Settings\Administrator\My Documents"
Kill P & "\" & "*.xlsx"
'You Can Specify Your Desired Path Where Your Excel Files are Located

You can Delete any of Your Desired File Types From Desired Locations as Follows:

'To Delete Text Document(.txt)Files
'Kill P & "\" & "*.txt"
'To Delete Word Document(.docx)Files
'Kill P & "\" & "*.docx"
'To Delete Image(.bmp,.jpg)Files
'Kill P & "\" & "*.bmp"
'Kill P & "\" & "*.jpg"

End Sub

'Please try to avoid the use of "Kill" statement in Your Macros,If You want delete some thing do it manually.

No comments:

Post a Comment

Hi User, Thank You for Visiting My Blog. Please Post Your Feedback/Comments/Query.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts