An item prefixed [F00000000] is neither read only nor pinned to the list
If the item is pinned a '1' is added to the
number thus "[F00000001]". If the item is Read
Only, then a '2' is added to the list, thus "[F00000002]", and if the
item is both read only and pinned the numbers are added
to one another thus"[F00000003]". You can
interrogate the registry entries with a macro to see
what the last number of the prefix is and act accordingly.
The following macro takes advantage of this.
Sub
ClearMRU2()
'Clear recent file list leaving the pinned items
Dim rFile As
RecentFile
Dim WSHShell, RegKey, rKeyWord
Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word\File
MRU\"
For Each rFile In
RecentFiles
rKeyWord = WSHShell.RegRead(RegKey & "Item " & rFile.Index)
Select Case
Mid(rKeyWord, 10, 1)
Case Is
= 0, 2
rFile.Delete
End Select
Next rFile
End Sub
The following version is
essentially similar but adds a user warnings and gives the user the opportunity to retain
(or clear) the pinned items when
clearing the list.
Sub
ClearMRU3()
Dim rFile As
RecentFile
Dim WSHShell, RegKey, rKeyWord
Dim sMsg1 As String
Dim sMsg2 As String
Dim sMsg3 As String
Dim sMsg4 As String
Dim sMsg5 As String
Dim
sMsg6 As
String
Dim sResponse
As String
Dim sPinned As String
Dim sListsize As Long
sMsg1 = "This will delete your recently used file list"
sMsg2 = "OK, we won't do that then!"
sListsize = RecentFiles.Maximum
sMsg3 = "Your recent file list has been cleared and reset to hold " _
+ Str$(sListsize) + " files." & vbCr
sMsg4 = "Clear Recent File List"
sMsg5 = " Do you wish to retain the items pinned to the recent file
list?"
sMsg6 = "Files pinned to the recent list have
been retained."
sResponse = MsgBox(sMsg1, vbOKCancel, sMsg4)
If sResponse = 1 Then
sPinned =
MsgBox(sMsg5, vbYesNo, sMsg4)
If sPinned = vbYes
Then
Set WSHShell =
CreateObject("WScript.Shell")
RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word\File
MRU\"
For Each rFile
In RecentFiles
rKeyWord = WSHShell.RegRead(RegKey & "Item " & rFile.Index)
Select
Case Mid(rKeyWord, 10, 1)
Case Is = 0, 2
rFile.Delete
End Select
Next rFile
MsgBox sMsg3 & sMsg6, vbInformation,
sMsg4
Else
For Each rFile
In RecentFiles
rFile.Delete
Next rFile
MsgBox sMsg3, vbInformation, sMsg4
End If
Else
MsgBox sMsg2,
vbInformation, sMsg4
End If
End Sub