Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 11-22-2014, 07:46 PM
whatsup whatsup is offline Is there a solution to change the recentfilelist programmatically Windows 7 64bit Is there a solution to change the recentfilelist programmatically Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a solution to change the recentfilelist programmatically Creating Event Handlers Programmatically pluviosilla Word VBA 4 11-06-2014 05:36 PM
Is there a solution to change the recentfilelist programmatically Adding macro to normal.dotm programmatically etippelt Word VBA 6 04-08-2013 05:55 PM
Programmatically convert Office documents to PDF from C# hemaneelagiri Office 0 10-21-2011 06:07 AM
outlook programmatically read an attachment into byte array chriskaza81 Outlook 0 11-19-2010 01:03 AM
Programmatically changing folder item selection Richard Cook Outlook 0 02-09-2007 02:25 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft