RecentFiles object (Word)

A collection of RecentFile objects that represents the files that have been used recently. The items in the RecentFiles collection are displayed at the bottom of the File menu.

Remarks

Use the RecentFiles property to return the RecentFiles collection. The following example sets five as the maximum number of files that the RecentFiles collection can contain.

RecentFiles.Maximum = 5

Use the Add method to add a file to the RecentFiles collection. The following example adds the active document to the list of recently-used files.

If ActiveDocument.Saved = True Then 
 RecentFiles.Add Document:=ActiveDocument.FullName, _ 
 ReadOnly:=True 
End If

Use RecentFiles (Index), where Index is the index number, to return a single RecentFile object. The index number represents the position of the file on the File menu. The following example opens the first document in the RecentFiles collection.

If RecentFiles.Count >= 1 Then RecentFiles(1).Open

The SaveAs and Open methods include an AddToRecentFiles argument that controls whether or not a file is added to the recently-used-files list when the file is opened or saved.

See also

Word Object Model Reference

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.