Removing files from Recents List (Excel 2007)

GeekGirlInFurs
Lounger
Posts: 47
Joined: 01 Feb 2016, 08:43

Removing files from Recents List (Excel 2007)

Post by GeekGirlInFurs »

Hi. I am using Excel 2007 and there are items in the Recents List that I would like to remove but can't find a way to do it.

There are no options for doing in the program itself that I can find.

I CAN remove the items from the Excel recent list that appears when right-clicking Excel in the Windows Task Bar, but that does not affect in the list that appears under the in-app File menu.

I searched the registry and found the items, associated with some keys "most recent" keys, but editing and/or removing those keys (after taking a backup) did not remove them from the list. That was a little surprising.

Years ago, I found online a Word template that included an Add-In that lets you remove items in Word's most recent list through a dialog box. I still use that. But I have no idea where I found it, and can't find anything like it for Excel.

Is there anyway to do this in Excel? could it be my version is too old?

Thank you!

robertocm
Lounger
Posts: 43
Joined: 07 Jun 2023, 15:34

Re: Removing files from Recents List (Excel 2007)

Post by robertocm »

[Update]

Solve here (sorry copy-paste):

Code: Select all

Sub Clearrecentfiles()
'Update 20140925
On Error Resume Next
Do Until Err.Number <> 0
Application.RecentFiles.Item(1).Delete
Loop
End Sub

[First test]
Tested this with Excel 2007 (i'm also using), but seems to be to delete the files!:

Code: Select all

Sub test()
Dim i As Integer
With Application.RecentFiles
    i = .Count
    For i = 1 To .Count
        Debug.Print .Item(i).Path
        '''''.Item(_i_).Delete
    Next i
End With
End Sub
Reference:
http://www.snb-vba.eu/VBA_Bestanden_en.html

User avatar
DocAElstein
4StarLounger
Posts: 584
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: Removing files from Recents List (Excel 2007)

Post by DocAElstein »

Those last two macros seem to work for me in my Excel 2007.
The first one removes the things shown in this list:
Recent Document List.JPG


The second macro shows me the full path to the things in that list in The Immediate window
Full path of the things shown in Recent List.JPG


Alan
You do not have the required permissions to view the files attached to this post.
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

snb
4StarLounger
Posts: 575
Joined: 14 Nov 2012, 16:06

Re: Removing files from Recents List (Excel 2007)

Post by snb »

Code: Select all

Sub M_snb()
    Application.RecentFiles.Maximum = 0
End Sub

User avatar
p45cal
2StarLounger
Posts: 147
Joined: 11 Jun 2012, 20:37

Re: Removing files from Recents List (Excel 2007)

Post by p45cal »

snb wrote:
15 Jul 2023, 10:01

Code: Select all

Sub M_snb()
    Application.RecentFiles.Maximum = 0
End Sub
Although this removes from sight all the entries in the recent files list, they all come back when the .Maximum value is restored.

snb
4StarLounger
Posts: 575
Joined: 14 Nov 2012, 16:06

Re: Removing files from Recents List (Excel 2007)

Post by snb »

This might be Windows version dependent:

Code: Select all

Sub M_snb()
    Kill CreateObject("wscript.shell").SpecialFolders(13) & "\*.*"
End Sub

User avatar
DocAElstein
4StarLounger
Posts: 584
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: Removing files from Recents List (Excel 2007) or put lots back, that's cool

Post by DocAElstein »

p45cal wrote:
15 Jul 2023, 13:05
snb wrote:
15 Jul 2023, 10:01

Code: Select all

Sub M_snb()
    Application.RecentFiles.Maximum = 0
End Sub
...this removes from sight all the entries in the recent files list, they all come back when the .Maximum value is restored.
All interesting stuff….. and I just tried giving it a bigger number than it was, ... and then I could look much further back at the files I had opened a while ago.
That can potentially be a good feature, at least for me with my hap hazard way of storing things: Occasionally I do something quick with a file, somewhere, and forget all about it, and then some time later want to find it.
It’s not a massive list that you seem to be able to get – it seems by me to be set to a limit of 9 in my Excel 2003, and 50 for 2007, 2010 1nd 2013. Still it is an improvement on the standard.
( It looks like it’s the same for Word as well. I have just set that to 50 on a computer that I was very busy on with Word 2013 over the last few months, and that has already been useful to get a better view of what and where I was doing stuff.)

Alan

(P.S. Clearing cookies and using my Bleach Bit does not clear the list)



_.________________________________________________________________________________________________________
You do not have the required permissions to view the files attached to this post.
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

User avatar
SpeakEasy
4StarLounger
Posts: 550
Joined: 27 Jun 2021, 10:46

Re: Removing files from Recents List (Excel 2007)

Post by SpeakEasy »

>Kill CreateObject("wscript.shell").SpecialFolders(13) & "\*.*"

Er ... that's the Music folder. The number for the Recent folder is 8.

snb
4StarLounger
Posts: 575
Joined: 14 Nov 2012, 16:06

Re: Removing files from Recents List (Excel 2007)

Post by snb »

@Speak

Like I said: It is windows version dependent.

User avatar
SpeakEasy
4StarLounger
Posts: 550
Joined: 27 Jun 2021, 10:46

Re: Removing files from Recents List (Excel 2007)

Post by SpeakEasy »

Code: Select all

OP's code of  14 Jul 2023, 19:57
Sub test()
Dim i As Integer
With Application.RecentFiles
    i = .Count
    For i = 1 To .Count
        Debug.Print .Item(i).Path
        '''''.Item(_i_).Delete
    Next i
End With
End Sub
The above works fine when displaying the path
Won't work fine if you are deleting items. The reason is that the moment an item in the list is deleted the list is recalculated. You need to work through the list backwards ...

User avatar
SpeakEasy
4StarLounger
Posts: 550
Joined: 27 Jun 2021, 10:46

Re: Removing files from Recents List (Excel 2007)

Post by SpeakEasy »

@snb With respect, SpecialFolders constants (CSIDLs) are fixed, they haven't changed since W95 (sure, new ones have been introduced, and some have had their display names modified, eg My Music -> Music, but if they changed what the constant actually referred to that would break the whole point of the special/known folders system.

The whole point of Special folders is to make it possible for any application to ask the operating system where an appropriate location for certain kinds of files can be found; independently of which version or user language of Windows is being used.

snb
4StarLounger
Posts: 575
Joined: 14 Nov 2012, 16:06

Re: Removing files from Recents List (Excel 2007)

Post by snb »

@speak

You are mistaken.

Apparently you are not familiar with the distinction between these 2 libraries:

CreateObject("shell.application") and CreateObject("wscript.shell")

User avatar
SpeakEasy
4StarLounger
Posts: 550
Joined: 27 Jun 2021, 10:46

Re: Removing files from Recents List (Excel 2007)

Post by SpeakEasy »

>Apparently you are not familiar with the distinction between these 2 libraries

Ah, but I am - I just read your code too casually, and assumed - because you were using a number - that you were using a CSIDL , rather than in index into a collection. In other words I didn't notice you were using wshShell's SpecialFolders - which, typically, you would access using a string value to avoid the version issue that you mention.

But apologies if you feel I was criticising you.

snb
4StarLounger
Posts: 575
Joined: 14 Nov 2012, 16:06

Re: Removing files from Recents List (Excel 2007)

Post by snb »

If you use the string it is language dependent: 'onlangs geopend' <> 'recent', 'bureaublad' <>'desktop'.
It is not an index but a constant.