Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Files accessed by the Office.Interop.Word.Range.InsertFile(...) method get added to the Recent list in Word's JumpList. Since the files we are inserting are temporary and promptly deleted, how do I either stop them from getting added or remove them afterward?

Everything I have found so far on JumpLists shows me how to add stuff (lots of stuff), and one place says you don't modify a JumpList once it has been Committed to Windows. I see things in Shell32 that look like they might be important parts of my answer, but I don't find enough to determine how to get the targets that they operate on.
Posted

I did find someone's solution in StackOverflow that I believe I can use:

1. Copy the JumpList file from its hidden location in [%AppData%]\Microsoft\Windows\Recent\AutomaticDestinations.
2. Perform the operation you don't want recorded.
3. Wait briefly for Windows to update the JumpList file (a few ms).
4. Overwrite the JumpList file with the original version.

Weird, but it works.
 
Share this answer
 
I hope i understand you well...

As far as i know, there is no method to control Word's JumpList using Interop (add or remove elements to/from list). But... there is a hope: How to clear the Most Recently Used list (MRU) list in Office programs[^]
Other useful information, you'll find here: Recently Used Documents[^]
 
Share this answer
 
Comments
John Whitmire 11-Dec-13 22:13pm    
Been there already. Clearing the list is not acceptable. I need the programmatic equivalent to "right-click and select 'Remove from this list'."
Maciej Los 12-Dec-13 2:02am    
I'm not talking about clearing list, but about deleting registry entry (selected name of file). Do you get it?
What version of MS Word?
John Whitmire 12-Dec-13 9:40am    
Targeting Word 2010. The human-readable registry entries are the MRU lists that show on the application window. Our unwanted entries do not appear there, so nothing is required for that.

The registry entries that appear to be the JumpList are in binary and I haven't found any reference on reading/modifying those entries. There is also the (virtual?) folder ...\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations with files named [guidAppId].automaticDestinations-ms that contain binary JumpList data (credit goes to nirSoft for that info), but I haven't found any descriptions of their data nor any means of obtaining the app ID guid for Word that would be required to know which file to access.

As stated in the question, our temporary files are added to the JumpList when the add-in calls Range.InsertFile(). Also of interest is the addition of the document template file (dotx) in the JumpList when Documents.Add() is called with a custom template. We don't want that one either, but I figured the solution to one is the solution to the other. There are flags on some system Open calls to suppress the addition of the file to the JumpList. I would hope for something similar in these Word methods. Or the inverse of SHAddToRecentDocs(...).
Maciej Los 12-Dec-13 12:32pm    
Have a look here: Removing items from Custom Category - Jumplist[^]

I have heard that WordApp.RecentFiles(1).Delete() solves problem by deleting the last added entry ;)
John Whitmire 12-Dec-13 13:43pm    
WordApp.RecentFiles is the Application MRU, not the JumpList managed by Windows that holds my unwanted entries. The WindowsApiCodePack provides mechanisms for managing a custom category in the JumpList, but not the Windows-managed Recent category. There is a method in shell32 for removing entries, but I don't know enough to figure out how to use it since it involves internal structures and interfaces that I can't yet comprehend.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900