Excel 2007 - Recent File List

  • Thread starter Thread starter Gerry Hickman
  • Start date Start date
G

Gerry Hickman

Hi,

The list of recently opened files appears to retain paths to files that
no longer exist on the system. Is there any way to change this, or to
remove files that no longer exist?
 
Would this work?

Sub RecentFiles_Delete_Invalid()
Dim rf As RecentFile
Dim s As String
For Each rf In Application.RecentFiles
s = Dir(rf.Path)
If s = vbNullString Then Application.RecentFiles.Item(rf.Index).Delete
Next
End Sub
 
Just an added note:

Sub Demo()
' Turn off, or Erase list
Application.RecentFiles.Maximum = 0
' Reset
Application.RecentFiles.Maximum = 50
End Sub

I believe the documentation of "9" for the "Maximum" is incorrect for
2007. If I'm not mistaken, I believe it's 50.

- -
HTH
Dana DeLouis
 
Oops! Me bad. The item is index only, therefore I believe you need to
delete them from the bottom up. Try this instead...

Sub RecentFiles_Delete_Invalid()
'// = = = = = = = = = = = = = = =
'// Remove files from MRU that no longer exists
'// = = = = = = = = = = = = = = =

Dim s As String
Dim j As Long

If .RecentFiles.Maximum = 0 Then Exit Sub

With Application
For j = .RecentFiles.Count To 1 Step -1
s = Dir(.RecentFiles.Item(j).Path)
If s = vbNullString Then .RecentFiles.Item(j).Delete
Next
End With
End Sub
 
Hi,

Interesting solution, but in this case I was looking for something
simple in the UI for home users.

Your code looks a bit like VBA, isn't it supposed to have all changed to
..NET these days?
 
isn't it supposed to have all changed to .NET these days?

VBA is alive and well in Office. And will be for a long time.
 
Hi Gerry
In case you have not find the easier answer, here you are go:
Clik Start - run - regedit - HKEY_CURRENT_USER \ Software \ Microsoft \
Office\ 12.0 \ Excel \ file MRU Click on it and from the right side find one
you want to remove and delete it.
As always, when you work with registry it´s good idea to make a backup of it
before making any changes (in the registry editor click on File - export and
save where you want).
And that´s it.
Regards
Teufik
 
Back
Top