Pages

Sunday, April 08, 2007

Delete Temporary Files

Sub Delete_Temp_Files_Primitive()

Dim sFileType As String ' Declare the Type of File
Dim sTempDir As String ' Temporary Directory

' ---------------------------------------------------------------
' Written By Shanmuga Sundara Raman for http://vbadud.blogspot.com
' ---------------------------------------------------------------

On Error Resume Next

sFileType = "*.tmp"
sTempDir = "c:\windows\Temp\" ' There might be mutiple temp directories (one for each profile) in Windows XP. Modify the code accordingly

Kill sTempDir & sFileType

' ---------------------------------------------------------------
' Delete Temporary Files, Excel VBA, Kill Statement
' ---------------------------------------------------------------

End Sub

2 comments:

  1. Good procedure. Will it work in VBscript? I tried it and I'm not sure VBscript recognizes the wildcard in "*.tmp"

    ReplyDelete
  2. Anonymous6:03 PM

    Dir Function with wildcards in VBScript

    Can you check the following link :http://www.source-code.biz/snippets/vbscript/1.htm

    ReplyDelete