How to open recent file momentary?

A

avkokin

Hello.
There is the code macro for open dialog "Recent Files" (below).
However when click "Open" on the some selected file then open new
dialog with this file. I'm obliged twice click that open some file.
Qustion: how to open some selected file from dialog "Recent Files" is
for single click? thank you very much.
My code:
Sub openDlgMRU()
im myPath As String
Dim bKey As String
bKey = System.PrivateProfileString("", "HKEY_CURRENT_USER\Software
\Microsoft\Office\11.0\Common\General", "RecentFiles")
myPath = Environ$("appdata") & "\Microsoft\Office\" & bKey & "\"
With Dialogs(wdDialogFileOpen)
.Name = myPath
If .Display = -1 Then
.Show
End If
End With
End Sub
 
J

Jean-Guy Marcil

avkokin said:
Hello.
There is the code macro for open dialog "Recent Files" (below).
However when click "Open" on the some selected file then open new
dialog with this file. I'm obliged twice click that open some file.
Qustion: how to open some selected file from dialog "Recent Files" is
for single click? thank you very much.

Change ther elevant part of your code with this:

With Dialogs(wdDialogFileOpen)
.Name = myPath
If .Show <> -1 Then
MsgBox "Action cancelled."
End If
End With


In your code, you use .Display to "display" the dialog box, but no action
will be taken.
Then, if the usr does not hit Cancelled, you "show" it and actions can be
taken.

So show it right away!

In the VBA help, read the differences between Display, Show and Execute as
they relate to dialog boxes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top