LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Excel 2007 "Recent" files not updating John Gee Excel Discussion (Misc queries) 1 May 28th 10 11:12 PM
Delete emty file names from "recent documents" Excel Touble in Excel Excel Discussion (Misc queries) 2 March 22nd 10 08:10 PM
Macro to delete Recent Files list (except those "pinned") - Excel Geoff Budd Excel Programming 3 October 21st 09 10:45 AM
How do I delete unpinned messages from my recent documenrts list? travelee21 Excel Discussion (Misc queries) 1 August 27th 09 01:54 AM
How do I delete items out of my "recent documents" list? susan carroll Excel Discussion (Misc queries) 2 August 17th 07 06:52 PM


All times are GMT +1. The time now is 11:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"