I have been able to configure an access form to open a word mail merge document.
The problem is that when the word document opens it opens all 41 records and displays the first mail merged record. I would like the word document to open the record that i am currently in when i click on my button from the Access form.
Ie in record number 23 merges word document to number 23, as opoosed to record number one.
Also is it possible to automatically save the document in a specified folder, C:/work and save it based on a feild name, in the access form. If the field name was 1982 then it would save as C:/work/1982.doc
My current code is listed below.
Any 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
The problem is that when the word document opens it opens all 41 records and displays the first mail merged record. I would like the word document to open the record that i am currently in when i click on my button from the Access form.
Ie in record number 23 merges word document to number 23, as opoosed to record number one.
Also is it possible to automatically save the document in a specified folder, C:/work and save it based on a feild name, in the access form. If the field name was 1982 then it would save as C:/work/1982.doc
My current code is listed below.
Any 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