Mail Merge Help!

Vaimpir

JAFO
Local time
Today, 16:26
Joined
Mar 5, 2004
Messages
78
I have looked through this forum and have found many answers but none that helps me do exactly what I need. I have a DB for clients that include, of course, names and and addresses. I want to be able to run a query and have the results merged to a word document. The problem I have is how to set that up but biggest of all is that I need to search box open to choose the word document that I want to merge to as there are many different letters/envelops/post cards that I need merge to at different times.

If someone can point me in the right direction I would appreciate it.

Steven
 
>>>

to open the word from access
and apply the results merged >>>

Set objApp = CreateObject("Word.Application")
objApp.Visible = True
strDoc = "c:/letters.doc"
objApp.Documents.Open strDoc

With objApp.ActiveDocument.MailMerge
.Destination = strPrint
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
objApp.Documents(strDoc).CloseSaveChanges:=wdDoNotSaveChanges
 
24 sharon,

thank you for the insite. I will give that a try but is there a way to set it up so I choose what document I want to mailmerge to?

Steven
 
I use a method covered in The Access Cookbook. I select my data using a query, then output it to a word doc. My Mailmerge template is already created to merge the data from this word doc, so I then open the template and the data is already in there. You could use the open save dialog box to locate and select the template to open or a combo box might be more preferable with the paths to the templates already loaded in. In which case conTemplate would get its value from the string in the combo box.

Private Const conTemplate As String = "A4msmltdmm.dot"
Private Const conQuery As String = "Q_WordMerge"
Private Const Path As String = "D:\SystemDbs"

Public Sub MMerge()

Dim objWord As Object
Dim strPath As String
Dim strDataSource As String
Dim doc


On Error GoTo HandleErrors
' Delete the rtf file, if it already exists.
strPath = FixPath(Path)
strDataSource = strPath & conQuery & ".doc"
Kill strDataSource

' Export the data to rtf format
DoCmd.OutputTo acOutputQuery, conQuery, _
acFormatRTF, strDataSource, False

' Start Word using mailmerge template
Set objWord = CreateObject("Word.Application")
Set doc = objWord.Documents.Add(strPath & conTemplate)

' Display the mail merge document
objWord.Visible = True

ExitHere:
Set doc = Nothing
Set objWord = Nothing
Exit Sub

HandleErrors:
Select Case Err.Number
Case 53 ' File not found
Resume Next
Case Else
MsgBox Err.Number & ": " & Err.Description
Resume ExitHere
End Select
Resume

End Sub


HTH
John
 
>>>

my idea is to make a table "pathName"
pathID (autonumber) [1,2,3...]
path (text) [c:/letter.doc, e:/sticker.doc...]
pathDES (text) [letter, sticker...

in your form you do a combobox <recordset from the table>, than you can choose what to open.

hope that u anderstand me ;)
 
Check out this mail merge example

Hello,
I found this MailMerge example VERY useful and it may do just what your are looking for. Check out the attached zip file to this message. It has a form that pops up allowing you to create a new mailmerge template, edit a current one, or use a currently created one. All the code is writtin for you. You just need to import the forms and code module into your Db project and make the call to start the merge. It's really pretty straightforward to use. If anybody knows where this originally came from please let me know also as I can't remember where I found this and can't seem to locate it again. Thanks. :)
Hope this helps and good luck!
Dana S
 

Attachments

DNS809904 said:
Hello,
I found this MailMerge example VERY useful and it may do just what your are looking for. Check out the attached zip file to this message. It has a form that pops up allowing you to create a new mailmerge template, edit a current one, or use a currently created one. All the code is writtin for you. You just need to import the forms and code module into your Db project and make the call to start the merge. It's really pretty straightforward to use. If anybody knows where this originally came from please let me know also as I can't remember where I found this and can't seem to locate it again. Thanks. :)
Hope this helps and good luck!
Dana S

With a little modifying I think this will be exactly what I'm looking for. Thank you for providing me with this.

Steven
 
and another example

office XP

put the 3 files in c:/


Good luck!
 

Attachments

Users who are viewing this thread

Back
Top Bottom