PDA

View Full Version : is there any macro to open temp file folder and delete temp files



prasadk
10-05-2021, 03:49 AM
Is there any VBA macro to open these 3 temp files folder by running the macro

C:\Windows\Prefetch


C:\Windows\Temp


C:\Users\Prasad\AppData\Local\Temp

and delete temp files in these 3 temp files folders

and after delete all temp files in these 3 temp files & then these 3 temp files folders should be close automatically

Logit
10-05-2021, 07:51 AM
Sub DeleteExample1()





'You can use this to delete all the files in the folder



On Error Resume Next





Kill "C:\Test\*.tmp"





Kill "C:\Windows\Temp\*.tmp"




Kill "C:\Users\Prasad\AppData\Local\Temp\*.tmp"


On Error GoTo 0






End Sub

prasadk
10-05-2021, 08:31 AM
i have applied this code in my excel it's not working

Logit
10-05-2021, 08:50 AM
It works here as desired.

Attached is a condensed version of the workbook that only addresses the > Kill "C:\Test\*.tmp" < folder.

Review how and where the code is located in this example workbook. I suspect you may have incorrectly
pasted or written the code.

Paul_Hossler
10-05-2021, 09:33 AM
i have applied this code in my excel it's not working


"Not Working" is not very specific

There could be many reasons: File permissions, file open, etc.

Try executing the macro steps manually and see if there are any errors

snb
10-06-2021, 01:53 AM
try



Sub M_snb()









Kill "C:\Test\*.*"


Kill "C:\Windows\Temp\*.*"


Kill "C:\Users\Prasad\AppData\Local\Temp\*.*"





End Sub