Class RecentFile (Word VBA)
The class RecentFile represents a recently used file. The RecentFile object is a member of the RecentFiles collection. To use a RecentFile class variable it first needs to be instantiated, for example
Dim rcnfl as RecentFile
Set rcnfl = 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 RecentFiles
Next rcnfl
Delete
Deletes the specified file on the list of recent files.
RecentFiles(1).Delete
Index
Returns a Long that represents the position of an item in a collection.
Dim lngIndex As Long
lngIndex = RecentFiles(1).Index
Name
Returns the name of the specified object.
Dim strName As String
strName = RecentFiles(1).Name
Open
Opens the specified object. Returns a Document object representing the opened document.
Sub OpenRecentFiles()
Dim rFile As RecentFile
For Each rFile In RecentFiles
rFile.Open
Next rFile
End Sub
Path
Returns the disk or Web path to the specified object.
The path doesn't include a trailing character — for example, "C:\MSOffice" or "https://MyServer". Use the PathSeparator property to add the character that separates folders and drive letters. Use the Name property to return the file name without the path.
Dim strPath As String
strPath = RecentFiles(1).Path
ReadOnly
True if changes to the document cannot be saved to the original document.
With RecentFiles(1)
.ReadOnly = True
.Open
End With