A family of Microsoft word processing software products for creating web, email, and print documents.
There are a number of ways to do this, but probably the simplest is to use the built-in Open dialog, which combines choosing the file and opening it into one operation. Try this instead of your call to Documents.Open:
With Dialogs(wdDialogFileOpen)
If .Show = -1 Then
Set oChanges = ActiveDocument
sFname = oChanges.Name
End If
End With
Another way is to use the Application.FileDialog object to get the name. Here's some sample code:
Sub x()
Dim sFname As String
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = Options.DefaultFilePath(wdDocumentsPath) & "\*.*"
.Show
If .SelectedItems.Count Then sFname = .SelectedItems(1)
End With
If Len(sFname) = 0 Then
' user canceled the dialog
Exit Sub
End If
' continue with rest of macro
MsgBox sFname
End Sub
You can set some additional properties of the FileDialog before calling .Show. For instance, there's a .FilterIndex property that sets the default in the file-type dropdown; if you want to limit the display to only *.docx files, set .FilterIndex = 3.