Question : Access VBA command to list Word docs for merging

I have used this script before but cannot find it.  The VBA is in the Access app.  The user clicks on a command button and a list of all Word docs in the same folder as the Access app is displayed in a drop down list.  The user selects the Word Doc which then opens.  Then the user merges the Access data into the Word doc.

Answer : Access VBA command to list Word docs for merging

Hmm. Perhaps Access doesn't have the Office reference by default, so we might have to use the Word dialogue. That makes it even simpler..
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Sub OpenSelectedDoc()
    Dim wdApp As Object 'Word.Application
    Dim fd As Object 'Word.Dialog
    
    On Error Resume Next
        Set wdApp = GetObject(, "Word.Application")
    On Error GoTo 0
    If wdApp Is Nothing Then
        Set wdApp = CreateObject("Word.Application")
    End If
    wdApp.Visible = True

    Set fd = wdApp.Dialogs(80) 'wdDialogFileOpen
    fd.Name = CurrentProject.Path & "\"
    fd.Show

End Sub
Random Solutions  
 
programming4us programming4us