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

Automating Word

Status
Not open for further replies.

ChopinFan

Technical User
Oct 4, 2004
149
US
I'm using Access 2K3 to do a mail merge in Word 2K3. I found the code below on Microsoft's site, but need to modify it. I have a .adp file with a SQL back end, however, and need to use a connection string to the server. I cannot simply substitute one in the "Name:" parameter, as it only accepts a file path. Any help is appreciated.

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\MyMerge.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Program Files\Microsoft " & _
"Office\Office\Samples\Northwind.mdb", _
LinkToSource:=True, _
Connection:="TABLE Customers", _
SQLStatement:="SELECT * FROM [Customers]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top