Recently Files and PushPins

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:

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...
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,222,644
Messages
6,167,290
Members
452,108
Latest member
Sabat01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top