Option Explicit
'API declaration to clear the "recent documents" list
Private Declare Sub SHAddToRecentDocs Lib "shell32" _
(ByVal uFlags As Long, ByVal pv As Any)
Sub ClearRecentDocs()
' Clear the 'Start' menu list
SHAddToRecentDocs 0, CLng(0)
' Clear Excel's list in the file menu and task pane
With Application
' If recent file tracking is already off, why clear?
If .DisplayRecentFiles = False Then
Exit Sub
Else
' If it's not, toggle the setting to clear
' and hide the task pane if it's visible
.DisplayRecentFiles = False
On Error Resume Next
.CommandBars("Task Pane").Visible = False
On Error GoTo 0
.DisplayRecentFiles = True
End If
End With
End Sub
Code:Option Explicit 'API declaration to clear the "recent documents" list Private Declare Sub SHAddToRecentDocs Lib "shell32" _ (ByVal uFlags As Long, ByVal pv As Any) Sub ClearRecentDocs() ' Clear the 'Start' menu list SHAddToRecentDocs 0, CLng(0) ' Clear Excel's list in the file menu and task pane With Application ' If recent file tracking is already off, why clear? If .DisplayRecentFiles = False Then Exit Sub Else ' If it's not, toggle the setting to clear ' and hide the task pane if it's visible .DisplayRecentFiles = False On Error Resume Next .CommandBars("Task Pane").Visible = False On Error GoTo 0 .DisplayRecentFiles = True End If End With End Sub
You can also record a macro of your actions while going through the steps of clearing the Recent Places List.