user4684804
user4684804

Reputation:

C# - How do I remove a file from the recent documents list in word?

Im trying to delete the Recent Document form the Recent menu in the MS Word, I tried delete the file in the RecentItems(in Explorer), but still my word shows the file in Recent Documents menu.

I found a solution to solve it using VB, VBA - How do I remove a file from the recent documents list in excel 2007?

How can i achieve this in c#?

Upvotes: -1

Views: 1479

Answers (2)

user2930590
user2930590

Reputation:

You can delete the entries in the registry from c#.

The key would be something like this:

HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Word\File MRU

For registry manipulation you can find lots of articles how to do that from C#.

Upvotes: 0

Philip Stuyck
Philip Stuyck

Reputation: 7457

You will have to use automation to do that. There are quite a few steps you have to take to get programming :

http://support.microsoft.com/en-us/kb/316384

  • Add a reference to Microsoft Word Object Library.

To do this, follow these steps : On the Project menu, click Add Reference. On the COM tab, locate Microsoft Word Object Library, and then click Select.

  • now you can get started :

with code like

object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ 

//Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();

oWord is the application object as in the VBA application. The recent file list and everything should be there.

Upvotes: 2

Related Questions