Class RecentFiles (Excel VBA)

The class RecentFiles represents the list of recently used files. To use a RecentFiles class variable it first needs to be instantiated, for example


Dim rfs as RecentFiles
Set rfs = Application.RecentFiles

For Each

Here is an example of processing the RecentFiles items in a collection.


Dim rcnfl As RecentFile
For Each rcnfl In Application.RecentFiles
	
Next rcnfl

Add

Adds a file to the list of recently used files.

Add (Name)

Name: The file name.


Application.RecentFiles.Add Name:="Oscar.xls"

Count

Returns a Long value that represents the number of objects in the collection.


Dim lngCount As Long
lngCount = Application.RecentFiles.Count

Item

Returns a single object from a collection.

Item (Index)

Index: The index number of the object.


Dim rcnflItem As RecentFile
Set rcnflItem = Application.RecentFiles(Index:=1)

Maximum

Returns or sets the maximum number of files in the list of recently used files. Can be a value from 0 (zero) through 50.


Application.RecentFiles.Maximum = 8