Excel

Clear Recent Documents List

Ease of Use

Easy

Version tested with

2000, 2002 

Submitted by:

Justinlabenne

Description:

Clears the list of recent documents available from the Start menu 

Discussion:

If you work on a shared computer and want to prevent others from trying to open some of your personal workbooks that you have buried and hidden somewhere on your network server, this code uses a simple API call to clear the listing of recently viewed documents. 

Code:

instructions for use

			

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

How to use:

  1. Open an Excel Workbook
  2. Copy the code
  3. Press Alt + F11 to open the Visual Basic Editor (VBE)
  4. Select INSERT > MODULE from the menubar
  5. Paste code into the right pane
  6. Press Alt+Q to return to Excel
  7. Save workbook before any other changes
 

Test the code:

  1. Go to TOOLS > MACRO > MACROS
  2. When the dialog appears, select {ClearRecentDocs}
  3. Press Run
 

Sample File:

KillRecentDocs.zip 7.74KB 

Approved by mdmackillop


This entry has been viewed 118 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express