Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA - How do I remove a file from the recent documents list in excel 2007?

The recent documents feature in Office is really useful, but I moved a file to a new directory and now I can't get Excel to stop hitting me with a "can't find this file" notification whenever I open a workbook. The Excel options seem only to control how many of these "recent documents" are displayed and not how many are actually saved. So I;'m wondering if there's a way in VBA to get at the list and remove the offending file.

like image 728
notnot Avatar asked Dec 09 '22 20:12

notnot


1 Answers

Try this...

Public Function TestIt()
    For i = 1 To Application.RecentFiles.Count - 1
        Dim answer As String
        answer = MsgBox("Delete " & Application.RecentFiles(i).Name, vbYesNo)

        If answer = vbYes Then
            answer = MsgBox("Are you sure?", vbYesNo)
            If answer = vbYes Then
                Application.RecentFiles(i).Delete
            End If
        End If
    Next i
End Function
like image 113
Jato Avatar answered Mar 05 '23 08:03

Jato