Hi @all
I understand you guys are talking of the recentfiles of office, not the one the OS provides.In this case you got the chance to temper with the list's items using the application-object recentfiles. It provides three methods:
.Open ---> to check if the file opens (if not an error occurs, and you can handle this one)
.Delete ---> to delete the item from the list
.Add ---> to add a new item, in this case the same item with the new path
The following example assumes that the second item in recentfiles doesn't open, due to a wrong Drive's name. The Drive of the path will be changed, and is added to the list:
Code:
Sub ChangeRecentFiles()
Dim strPath As String, strName As String
Dim strNewDrive As String
Dim strNewPath As String, strNewName As String
Dim lngFile As Long
strNewDrive = "H:"
lngFile = 2
strName = Application.RecentFiles.Item(lngFile).Name
strPath = Application.RecentFiles.Item(lngFile).Path
strNewPath = strNewDrive & Right(strPath, Len(strPath) - 2)
On Error GoTo DeleteListItem
Application.RecentFiles.Item(lngFile).Open
Exit Sub
DeleteListItem:
Application.RecentFiles.Item(lngFile).Delete
Application.RecentFiles.Add Name:=strNewPath
strNewName = Application.RecentFiles.Item(1).Path
End Sub
Cheers