Mail merge wooooooos

J

Jim Rendant

I am having problems with office 2003 and mailmerge from access using VBA.

I set the merge document name (mergedoc) to the file to use for the main
document. Based on the type of document I also create a SLQstr to retrieve
the proper data for that particular main document.

When I open the document I get a "Confirm DataSource" dialog box which I am
hoping NOT to see since I belive I have provided the proper information to
OpenDataSource.

After confirmation, the document does gets merged, printed and the merge
document closed BUT the word application DOES NOT close which is al required
since i want to fully automate this process

Thanks In Advance .....

Here is the code:

Set objWord = GetObject(mergdoc, "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="q:\photography.mdb ", _
LinkToSource:=True, _
ReadOnly:=True, _
Connection:="TABLE Picture_Data", _
SQLStatement:=SQLSTR

' Execute the mail merge.
objWord.MailMerge.Execute
objWord.Application.ActivePrinter = "\\manager\HP LaserJet 5/5M PostScript"
'objWord.Application.PrintOut

objWord.Application.Documents(1).Close (wdDoNotSaveChanges)
objWord.Close (wdDoNotSaveChanges)

Set objWord = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top