Solved

Word Mail Merge from Access Table Problem

Posted on 2010-08-22
2
507 Views
Last Modified: 2012-05-10
I am trying to merge the value from an Access 2007 table to a Word document mail merge.  The table will only have one record.  The word document    Quote.doc is set up with the fileds and is pointed at the database  C:\Documents and Settings\All Users\Desktop\QuoteMaster.accdb

When the code runs, I receive an error in Word:
Could not find file C:\Documents and Settings\All Users\Desktop\Quotes.mdb'.

in Access, I get a Visual Baisc Error:
Run-time error '5922':
Word was unable to open the data source.

When I click debug, the following is highlighted:
objDoc.MailMerge.OpenDataSource _
Name:="C:\Documents and Settings\All Users\Desktop\Quotes\QuoteMaster.accdb", _
LinkToSource:=True, Connection:="TABLE tblSendQuote", _
SQLStatement:="SELECT * FROM tblSendQuote]"


Any help would be appreciated.


Private Sub cmdPrintQuote_Click()
Dim FILENAME As String
Dim objWord As New Word.Application
Dim objDoc As Word.Document
'Make Word visible
objWord.Application.Visible = True
'Sets the Word document to do the mail merging
Set objDoc = objWord.Documents.Open("c:\Quotes\Quote.doc")
objWord.Application.Visible = True
'Set the mail merge data source
objDoc.MailMerge.OpenDataSource _
Name:="C:\Documents and Settings\All Users\Desktop\Quotes\QuoteMaster.accdb", _
LinkToSource:=True, Connection:="TABLE tblSendQuote", _
SQLStatement:="SELECT * FROM tblSendQuote]"

objDoc.MailMerge.Destination = wdSendToNewDocument
objDoc.MailMerge.Execute
    
FILENAME = "Test File.doc"
objWord.Application.Documents(1).SaveAs ("C:\Quotes\" & FILENAME)
objWord.Application.Documents(2).Close wdDoNotSaveChanges
objWord.Application.Documents(FILENAME).Close
    
Set objWord = Nothing
Set objDoc = Nothing
End Sub

Open in new window

0
Comment
Question by:Scamquist
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
GrahamMandeno earned 500 total points
ID: 33497952
It appears you have an unmatched bracket in line 14.  Either delete the closing bracket or add an opening bracket before tblSenQuote.
--
Graham
0
 
LVL 1

Author Closing Comment

by:Scamquist
ID: 33498062
I am not going to admit how much time I spent monkeying around with this.  Some times it just takes another set of eyes to see the obvious.  Thank you so much for the assist.  

Steve

0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question