Search code examples
vbataskbarjump-listrecent-file-list

Disable jumplist entries in Windows 7 for VBA-generated Office documents


I am programmatically generating Office Documents (in my case Word or Excel 2007) using automation in VBA (in this example MS Access 2007, but that should not change much) under Windows 7. This works fine.

Since the documents are automatically generated I don't want them to show up in the recent lists. For recent list in Word I can just add "AddToRecentFiles:=False" when saving the document (see example) or I could delete the entries afterwards through "Application.RecentFiles ..."

My code

Set objWord = CreateObject("Word.Application")

Set curDocument = objWord.Documents.Add

curDocument.SaveAs FileName:=Folder + "text.doc", FileFormat:=wdFormatDocument, 
            AddToRecentFiles:=False
curDocument.Close

Problem is I could not find a way to disable the recent lists from Windows 7 (i.e. jump list with recent items in the taskbar for Word or last used folders in Explorer and recent list for Word in Start menu). Example of a Windows7-jumplist for Word 2007 filled up with links to autogenerated documents

I am aware these lists are stored under %APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations and I have found out that to manipulate Jumplist there is the "WindowsAPICodePack" (that I can not use from VBA, right?).

To add an item the the recent list I can use the old API SHAddToRecentDocs from the "shell32.dll" library but deleting with this API function does not work anymore as it only seems to affect the entries in the old "/recent" folder (and even deletes everything what is not my intention). Presentations on the Windows 7 Taskbar API too only seem to mention how to add items but not how to avoid doing so or to delete specific entries.

Am I missing something or is there no -- easy and ideally usable from within VBA -- way to manipulate (or temporerally disable) the recording Windows 7 does?

Kind regards Andreas


Solution

  • I have encountered a similar problem when programmatically dealing with Word and other office documents with Sharepoint.

    You can access the JumpList object via the PresentationFramework library (.Net 4) or the WindowsAPICodePack for 3.5 (and possibly earlier) however there does not appear to be a way to programmatically delete JumpListItems.

    I found a post which suggests that you can disable Word from adding items to the JumpList via registry key. http://www.add-in-express.com/forum/read.php?PAGEN_1=2&FID=5&TID=8124#nav_start This shouldn't be too hard to do programmatically (if you have admin rights on the machine generating the documents).

    I haven't had a chance to try out whether this works yet. If you find a more elegant solution please let me know!

    Update: In my solution I ended up regenerating the jumplist based on the Word Recent files list (I looped backwards through the internal Word recent files list and called JumpList.AddToRecent method for each file).