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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

merge code creates new document

Status
Not open for further replies.

emitecaps

Technical User
Apr 20, 2005
24
GB
Hi,

I have some code that I've borrowed from elsewhere to enable me to run a mailmerge to email from access.
the problem i have is that when the merge begins it always creates a new document called "Electronic Message 1"
Here's the code...


Private Sub Command1_Click()


Set oApp = CreateObject("Word.Application")
oApp.Application.Visible = True
oApp.Application.Documents.Open "c:\ run query material.doc"

With oApp.ActiveDocument.mailmerge
.Destination = wdSendToEmail
.MailAsAttachment = True
.MailAddressFieldName = "EMail"
.MailSubject = "Material"


.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With

oApp.Quit
Set oApp = Nothing
End Sub

Also I'm trying to set the subject line as a mergefield..."Material" and also "Issue_Date" but this just isn't working...

any tips would be greatly appreciated!

thanks
B
 
Hi!

If you record the mailmerge in a macro in the Word Document and call the macro autoexec. Then you can open the Word Doc from Access using a hyperlink and the mail merge will automatically run.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top