Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to delete "unpinned" recent files
I have the following macro to remove all the recently open file names (except
those that are "pinned") from the Office Button in Excel 2007 - kindly supplied by one of the experts in these forums: Sub ClearMRU_NotPinned() Dim rFile As RecentFile Dim WSHShell, RegKey, rKeyWord Set WSHShell = CreateObject("WScript.Shell") RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\ Excel\File MRU\" For Each rFile In Application.RecentFiles rKeyWord = WSHShell.RegRead(RegKey & "Item " & rFile.Index) If InStr(1, rKeyWord, "[F00000000]") Then rFile.Delete End If If InStr(1, rKeyWord, "[F00000002]") Then rFile.Delete End If Next rFile End Sub However, when I run it, I get the following error message: Run-time error '1004' Application-defined or object-defined error The debug highlights the statement: rKeyWord = WSHShell.RegRead(RegKey & "Item " & rFile.Index) Has anybody got any ideas on what I need to do to make this work? (P.S. I had a recent thread for this, but it dried up after a couple of responses, so I'm opening it again from where it left off, in the hope of resolving this problem). Many thanks. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
MS Excel 2007 "Recent" files not updating | Excel Discussion (Misc queries) | |||
Delete emty file names from "recent documents" Excel | Excel Discussion (Misc queries) | |||
Macro to delete Recent Files list (except those "pinned") - Excel | Excel Programming | |||
How do I delete unpinned messages from my recent documenrts list? | Excel Discussion (Misc queries) | |||
How do I delete items out of my "recent documents" list? | Excel Discussion (Misc queries) |