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

MailMerge in Access

Status
Not open for further replies.

stnkyminky

Programmer
Oct 15, 2001
476
US
I am trying to execute the following code in an Access application. The code will open Word but hangs on the open datasource window. I assume that window shouldn't appear since I am providing the source thru code.

BTW The client machine is using MS Access runtime.

Thanks

Dim objWord As Word.Application
Dim objDoc As Word.Document


On Error GoTo errorhandler

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("m:\scott\ship_1.doc")
' Make Word visible.
objWord.Application.Visible = True

objDoc.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="TABLE tbl_sw_ron's_shipments", _
SQLStatement:="Select * from tbl_sw_ron's_shipments"
' Execute the mail merge.
objDoc.MailMerge.Execute


Set objDoc = Nothing
Set objWord = Nothing

Exit Function
errorhandler:
MsgBox Err.Description & " " & Err.Number
Set objDoc = Nothing
Set objWord = Nothing Scott
Programmer Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top