Detect Pinned RecentFiles in (Excel 2007) VBA or Other?

Is there a way, in addition to scanning the registry, to determine that the RecentFile object RecentFile pinned in the Recent Documents list? From VBA to preference, something that can live in an add-in.

Reference Information. I want to convince Excel to β€œfloat” attached items at the top (or bottom) of the list, which can be achieved by reusing them in RecentFiles if I could identify the items of interest.

I see in the registry (within HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\File MRU ) that the pinned item is identified there, for example:

 [F00000001][T01CC04D632020F50]*C:\Files\ThisOneIsPinned.xlsx [F00000000][T01CBFB8F14408960]*C:\Files\ThisOneIsNot.xlsx 

... so there’s a way to get closer to him, I suppose. I would prefer something a little less, uh, fun ..

+4
source share
1 answer

To access the list of recent files in VBA use

 Sub test() Dim objAllRecentFiles As Object Set objAllRecentFiles = Application.recentfiles End Sub 

I do not believe that there is an alternative way, besides using the registry, to determine if the latest files are attached or not. In the example below, you can view all the latest files, identify those that are not attached, and modify the registry so that they are pinned. Commented removal method

 Sub test2() Dim objAllRecentFiles As Object Dim WSHShell, RegKey, rKeyWord Set WSHShell = CreateObject("WScript.Shell") Set objAllRecentFiles = Application.recentfiles RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\File MRU\" For Each rFile In objAllRecentFiles rKeyWord = WSHShell.RegRead(RegKey & "Item " & rFile.Index) If InStr(1, rKeyWord, "[F00000000]") Then 'Delete registry 'rFile.Delete 'Change registry setting to make recent file pinned strPinned = Replace(rKeyWord, "[F00000000]", "[F00000001]") WSHShell.Regwrite (RegKey & "Item " & rFile.Index), strPinned, "REG_SZ" End If Next rFile End Sub 
+3
source

All Articles