Prevent a file from showing up on the recently used files list

Article contributed by Bill Coan

Turn off the list when the document opens and turn it back on again when the document closes.

In order to do this, you need to create some document variables to store the user's original settings. Then you need to capture those settings and store them in the document variables before turning off the list. Finally, you need to use the document variables to turn the list back on with the user's original settings. A separate subroutine is used for each of these actions. Generally speaking, you will want to call these routines from the Document_Open and Document_Close events.

Sub CreateDocumentVariables()

ActiveDocument.Variables.Add Name:="DisplayRecentFiles", Value:="0"
ActiveDocument.Variables.Add Name:="RecentFilesMaximum", Value:="0"

End Sub

Sub RecordUserOptions()

''make a record of user settings so they can be restored after my
''last document is closed
ActiveDocument.Variables("DisplayRecentFiles") =
ActiveDocument.Variables("RecentFilesMaximum") =

End Sub

Sub SetTemporaryOptions()

'Change user options to suit my requirements
Application.DisplayRecentFiles = True
Application.RecentFiles.Maximum = 4

End Sub

Sub RestoreUserOptions()

'restore user settings to what they were before my first doc was opened
Application.DisplayRecentFiles =
Application.RecentFiles.Maximum =

End Sub

Click to view Terms of Use page

Click to view Disclaimer page