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

Problems with OpenDataSource Name: and Word Merge

Status
Not open for further replies.

batteam

Programmer
Sep 12, 2003
374
US
I want to merge a Word document with a record in an Access (.adp) table - in SQL. I cannot get the syntax correct in the .OpenDataSource Name: = or how to get the SQLStatement:= defined correctly. My code now is:

sDBPath = "Y:\xxx\xxx\mydbname.adp"

With Doc.MailMerge
.OpenDataSource Name:=sdBPath, _
LinkToSource:="True", _
SQLStatement:="SELECT * from dbo.GI_mytblename"

etc...
etc..

Any help is really appreciated. Thanks.
 
how about

with Doc.MailMerge.OpenDataSource
.name = sdBPath
.LinkToSource ="True"
.SQLStatement ="SELECT * from dbo.GI_mytblename"



End wit
 
Thanks but did not help. Still working on it.
 
try this it works for me
Code:
Set woobj = CreateObject("Word.Application")
With woobj
    .Visible = True
    .Documents.Open Templatename    
 .ActiveDocument.MailMerge.OpenDataSource Name:=CurrentProject.FullName, SqlStatement:="MySqlStatement
    .ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False
    .ActiveDocument.MailMerge.Execute 0
    .ActiveDocument.Fields.Update
    Do While result = vbNo
        .ActiveDocument.PrintOut
        result = MsgBox("Did Letter Print OK?", vbYesNoCancel + vbQuestion, CurrentProject.Properties("AppTitle"))
    Loop
    .Documents.Close 0
    .Quit
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top