How to clear Recent Places

rdwray

New member
Joined
Mar 25, 2017
Messages
38
Reaction score
0
Points
0
Excel Version(s)
2010
How to clear "Recent Places" list with VBA, I have a hidden folder that I do not want the path for it displayed.
 
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
 
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

Thanks, but not the "Recent File" list, the "Recent Places" list.
 
@rdw
Please do not quote entire posts unnecessarily. They are just clutter -Thx
 
You can also record a macro of your actions while going through the steps of clearing the Recent Places List.

Office 2010 will not allow you to record a macro if you have to do it in "Option", it simply gives you a blank.
 
Not being argumentative, and it can be edited, but the forum automatically quotes the entire post that you are replying - I will keep your suggestion in mind as I did with Logit.
 
Use the "reply to thread" button. If it works for me it should work for you
 
Back
Top