Class RecentFile (Excel VBA)

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


Dim rcnfl as RecentFile
Set rcnfl = Application.RecentFiles(Index:=1)

For Each

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


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

Delete

Deletes the object.


Application.RecentFiles(1).Delete

Index

Returns a Long value that represents the index number of the object within the collection of similar objects.


Dim lngIndex As Long
lngIndex = Application.RecentFiles(1).Index

Name

Returns a String value that represents the name of the object.


Dim strName As String
strName = Application.RecentFiles(1).Name

Open

Opens a recent workbook.


Dim wb As Workbook
Set wb = Application.RecentFiles(1).Open

Path

Returns a String value that represents the complete path to the workbook or file that this RecentFile object represents.


Dim strPath As String
strPath = Application.RecentFiles(1).Path