Mail Merge with Word HELP

CandyBoy

New member
Local time
Today, 08:05
Joined
Sep 28, 2001
Messages
8
I am trying to put a command button on a form that would send the current data on the form (or in the table) to a Word Mail Merge. Any help or sample code would be of great help. Thx in advance
 
I sent you the Mail Merge code where a mail merge document was already there. This code will send the current record data only and uses BOOKMARKS rather than merge fields and mail merge.

FirstName and LastName are two bookmarks set up in the word document.


Private Sub Command7_Click()
Dim dbs As DAO.Database
Dim rstMergeThese As Recordset
Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

With oApp
.Documents.Open "C:\My Documents\DataMailMerge.doc"
' Move to each bookmark and insert text from the form.
.ActiveDocument.bookmarks("FirstName").Select
.selection.Text = (CStr(Forms!frmForm1!FirstName))
.ActiveDocument.bookmarks("LastName").Select
.selection.Text = (CStr(Forms!frmForm1!LastName))




'if word isn't running, start and activate it
If Err Then
Shell "C:\Program Files\Microsoft Office\Office\" & "WinWord / Automation", vbMaximizedFocus
AppActivate "Microsoft Word"
End If
' Print the document in the foreground so Microsoft Word 97
' will not close until the document finishes printing.
.ActiveDocument.PrintOut Background:=False
' Close the document without saving changes.
.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
' Quit Microsoft Word 97 and release the object variable.
.Quit
Set oApp = Nothing

End With

End Sub
 

Users who are viewing this thread

Back
Top Bottom