PDA

View Full Version : "Recent Documents" list in Word 2007/2010



acantor
02-14-2011, 07:41 AM
Is there a programmatic way to access the "Recent Documents" list? I have tried sending keystrokes via the user interface. Since Alt + F activates the Office button/File ribbon, then...

SendKeys "%f"
SendKeys "{right}"

But when I assign the macro to Alt + D(which is how I want this to work), the hotkey Alt + the SendKeys Alt conflict. I have also tried

SendKeys "{F10}" ' an alternative way to focus the ribbon
SendKeys "f"
SendKeys "{right}"

But the hotkey Alt causes the SendKeys statement to send Alt + F10, which by default is AppMaximize. I disabled Alt + F10, but still no luck.

Since the quick-and-dirty solutions are not working, I am hoping to find a more elegant and direct way to access the list of recent documents, and assign it to Alt + D.

Tinbendr
02-14-2011, 08:38 AM
Sub RecentFiles()
Dim Rnt As String
For Each Rcnt In Application.RecentFiles
Debug.Print Rcnt
Next

End Sub



David

acantor
02-14-2011, 09:08 AM
Thanks for this, David. I can see that your code processes all of the documents in the Application.RecentFiles collection, but the list of documents is not displayed, so a document cannot be chosen.

Tinbendr
02-14-2011, 09:43 AM
Ok, you need a builtin dialog, maybe.

I'm not good at manipulating the menu through sendkeys.

Maybe someone else can pipe in.

Paul_Hossler
02-14-2011, 09:49 AM
If you just want to pick a file from the MRU, I'd read them into a list box and pick it

It's easy enough to mod if you just want the open ones

Out of courousity, what are you trying to do?

Paul

acantor
02-14-2011, 10:02 AM
Not exactly. I want to produce the same list of documents that appears in "Recent Documents," i.e., the list that allows a user to scroll through the list of recent documents, and choose one to open.

The "ideal" solution would be to give direct access to the list of Recent Documents: that's the list that is to the right when you click (or otherwise give focus) to the Office button.

Background: One of my clients is blind, and accesses a computer via a screen reader. In Word 2003, I added "&Documents" as a top-level menu. This custom menu contained only the list of recently opened documents. (I constructed it by making a copy of the "File" menu, and deleting everything from it except the list of recent documents.)

Now, my client is migrating to Word 2010. Screen reader access to ribbons is more complicated than screen reader access to menus, and he asks that that keyboard interaction with Word 2010 be as similar as practical to what he is used to.

acantor
02-15-2011, 12:56 PM
Another way to put this:

Is there a way to display only the list of Recent Documents, with its "pin" buttons, that normally appears to the right of the Office button/File ribbon?

Paul_Hossler
02-15-2011, 06:20 PM
In 2010


SendKeys ("%fr")

SendKeys ("%fr2")



the first will activate the MRU and the second will open the second document

I don't know if the speech / reader will work, but the menus open

Paul