[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Word Mail Merge from Access Table Problem

Posted on 2010-08-22
2
Medium Priority
?
510 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

656 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