hatman
Well-known Member
- Joined
- Apr 8, 2005
- Messages
- 2,664
In my 2003 platform for a Dictator Application, I had a very robust recently used file list separate from the native Excel list. In my 2007 platform, I am retasking the Office Button, including replacement of the recetly used file list. In trying to make it robust, I am in the process of developing the followng code:
Three problems I see so far:
1) I am not sure how it will behave if teh user has a partially populated file list, or maximum number of files specifies other than 20.
2) I cannot find where the object model exposes the pushpin status for each file in the list. The above code works very well, as long as no files are locked into the list... if a file is locked on the list, it gets "held over" rather than being replaced with athe new entry.
3) I need to figure out how to intercept the event when a user clicks on an item in the list, and run a routine instead of letting Excel try and open the file...
Has anyone tried doing this... and do you have any wisdom to share. At this point, number 1 is a minor annoyance that I think will sort itself out with some beta testing and tweaking. Number 2 may end up making this solution less robust than I would like it to be. Number 3 may stop me in my tracks if I can't figure it out...
Code:
Global Const App_Name As String = "PES_Electrical_Crossref"
Global Const Sect_1 As String = "Recent_Files"
Global Const Sect_2 As String = "Recent_Files_XL"
Global Const File_Count As Integer = 9
Sub Replace_Recent_Files()
Dim Item_Rcnt As RecentFile
Dim cnt As Integer
With Application.RecentFiles
'if app crashed in last session, do NOT overwrite the original list with the replacement list
If GetSetting(App_Name, Sect_2, 0, "") <> "" Then
Exit Sub
End If
SaveSetting App_Name, Sect_2, 0, .Maximum
For Each Item_Rcnt In Application.RecentFiles
SaveSetting App_Name, Sect_2, Item_Rcnt.Index, Item_Rcnt.Path
Next Item_Rcnt
For cnt = File_Count To 1 Step -1
.Add GetSetting(App_Name, Sect_1, cnt, "")
Next cnt
.Maximum = File_Count
End With
End Sub
Sub Restore_Recent_Files()
Dim cnt As Integer
With Application.RecentFiles
.Maximum = GetSetting(App_Name, Sect_2, 0, 20)
For cnt = GetSetting(App_Name, Sect_2, 0, 20) To 1 Step -1
.Add GetSetting(App_Name, Sect_2, cnt, "")
Next cnt
DeleteSetting App_Name, Sect_2
End With
End Sub
Three problems I see so far:
1) I am not sure how it will behave if teh user has a partially populated file list, or maximum number of files specifies other than 20.
2) I cannot find where the object model exposes the pushpin status for each file in the list. The above code works very well, as long as no files are locked into the list... if a file is locked on the list, it gets "held over" rather than being replaced with athe new entry.
3) I need to figure out how to intercept the event when a user clicks on an item in the list, and run a routine instead of letting Excel try and open the file...
Has anyone tried doing this... and do you have any wisdom to share. At this point, number 1 is a minor annoyance that I think will sort itself out with some beta testing and tweaking. Number 2 may end up making this solution less robust than I would like it to be. Number 3 may stop me in my tracks if I can't figure it out...