To clear recycle bin with VBA

Maurizio

Well-known Member
Joined
Oct 15, 2002
Messages
687
Office Version
  1. 2007
Platform
  1. Windows
Hi, is there a way in order to clean up recycle bin by vba?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
On 2002-11-04 16:14, maurizio.rota wrote:
Hi, is there a way in order to clean up recycle bin by vba?

You will have to use some Win API's to do this;

<pre/>
Option Explicit

Private Declare Function EmptyRecycleBin Lib "shell32.dll" _
Alias "SHEmptyRecycleBinA" ( _
ByVal hwnd As Long, _
ByVal pszRootPath As String, _
ByVal dwFlags As Long) As Long

'// Just a basic emptying of the Folder
Sub RecycleBin_Empty()
Dim Para As Long
Dim lngRet As Long

lngRet = EmptyRecycleBin(0&, vbNullString, 0&)

End Sub

</pre>
 
Upvote 0
Is there a way to prevent the message box appearring i.e. Are you sure you want to permanently delete all of these items?
 
Upvote 0
Try using:
Code:
lngRet = EmptyRecycleBin(0&, vbNullString, 1&)
 
Upvote 0

Forum statistics

Threads
1,215,824
Messages
6,127,092
Members
449,358
Latest member
Snowinx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top