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

Still can't get Word Mail Merge correct

Status
Not open for further replies.

charle525

MIS
Jul 18, 2003
23
0
0
US
I've been working on this mail merge for a while and can't get it right (Office XP). I want the document to merge from a query that is already in the database and then to be filtered to only the record that is showing on the form. The code I've found in other threads is all similar but doesn't quite work for me. Here is some of my code:

Dim objWord As Word.Document

Set objWord = GetObject("C:\COEWork\Letter_TBV.doc")
objWord.Application.Visible = True

objWord.MailMerge.OpenDataSource
CurrentProject.Path, , , , True, , , , , , , "QUERY
qryStudentMinor", "Select * from [qryStudentMinor]
WHERE [id]='" & Me!txtID & "'"

objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute

I've used the actual DB path instead of CurrentProject.Path and that hasn't worked either. I've tried my word document with the data source already set to the DB and with it empty and just the merge fields in the body. When I press the form button, Word opens and I get a "Confirm data source" dialog box and I don't know why. Do I need to set up an actual ODBC data source? Do I need to change my code? The word document? Please help! Thanks.
 
I'm not up on the new fangeled procedures but this has worked since Office '97

Dim stAppName, macroname As String
macroname = "Printme"
stAppName = "C:\Microsoft Office97\Office\WINWORD.EXE c:\Mydoc.doc /Mmacroname"
Call Shell(stAppName, 1)

DougP, MCP
 
Thanks, but I'm not sure that will work. My code matches what multiple people have suggested but doesn't work. I still get this dialog to confirm data source when Word opens. I'm wondering if something is set wrong in the db, in Word, or if I need to create an ODBC DSN?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top