Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail merge documents from an access form

Status
Not open for further replies.

oggstar

Technical User
Sep 8, 2001
18
0
0
AU
I am using the following expression that will open and display a mail merge word document from an access form. The only problem is that it opens the first record of the query as opposed to the specific record that i am in.

How do i open up the specific record and is it possible to automatically save the mail merge document in a specific directory which is named after a feild name such as 2142.doc

Thanks and help greatly appreciated.

Private Sub Command117_Click()
On Error GoTo Err_Command117_Click
' Button launches Word and opens a specified document
' And runs an optional macro. the macro could print out the word doc and quit

Dim retval As Variant
Dim DocName, MacroName As String
' Drive and Full path to name and location of Word document
DocName = "E:\mergetemp.doc"

'Optional Macro Name. Note Word Macro name cannot have any spaces in it.
'MacroName = "/M" & "MacroName"

'Note full path to Word including Drive and folder
retval = Shell("C:\Program Files\Microsoft Office\Office\winword.exe" & " " & DocName & MacroName, vbNormalFocus)

Exit_Command117_Click:
Exit Sub

Err_Command117_Click:
MsgBox Err.Description
Resume Exit_Command117_Click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top