473,698 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error 5922 when opening a mailmerge document in Word

3 New Member
Platform: Access 2003 SP2 and Windows XP.

I've tried a number of different scenarios and none of them seem to work

The "OpenDataSource " statement gives a Run-time error 5922. Please help find my error.

'************** *************** ***************

Dim wdApp As Word.Applicatio n, wd As Word.Document, strConnection As String
Set wdApp = CreateObject("W ord.Application ")
wdApp.Visible = False
xPathDoc = "C:\Documen ts and Settings\BDA Software\LienWa iver.doc"
Set wd = wdApp.Documents .Open(xPathDoc, , True)
Dim wdMM As Word.MailMerge, strSourceFile As String
Set wdMM = wdApp.Documents (xPathDoc).Mail Merge
With wdMM
.MainDocumentTy pe = wdFormLetters
.OpenDataSource Name:="C:\Docum ents and Settings\BDA Software\Databa se.mdb", _
LinkToSource:=T rue, _
Connection:="TA BLE tblLienWaiver", _
Sqlstatement:=" SELECT * from tblLienWaiver"
.Destination = wdSendToPrinter
.SuppressBlankL ines = False
With .DataSource
.FirstRecord = wdDefaultFirstR ecord
.LastRecord = wdDefaultLastRe cord
End With
.Execute 'Pause:=False
End With

Set wdMM = Nothing
wd.Close wdDoNotSaveChan ges
wdApp.Quit
Set wdApp = Nothing
Exit Sub
' *************** *************** ***
Thank you, Willis
Nov 27 '06 #1
4 7738
NeoPa
32,569 Recognized Expert Moderator MVP
Willis,

Could you please post the Error Message and perhaps repost the code in the code tags formatted as it would be normally.
That would make life so much easier.
It's really hard to scan through code without any of the visual symbols included in normal code formatting (indentation etc).
Nov 27 '06 #2
Willis Wilson
3 New Member
Willis,

Could you please post the Error Message and perhaps repost the code in the code tags formatted as it would be normally.
That would make life so much easier.
It's really hard to scan through code without any of the visual symbols included in normal code formatting (indentation etc).
*************** **
Below is the code, however the following is selected when I get:
Microsoft Office Word
This operation cannot be completed because of dialog or database engine failures. Please try again later
After clicking 'Okay' the following error message is returned:
Run-time Error '5922'
the code in quotes is highlighted
*************** ******

Expand|Select|Wrap|Line Numbers
  1. Dim wdApp As Word.Application
  2. Set wdApp = CreateObject("Word.Application")
  3. wdApp.Visible = False
  4. xPathDoc = "C:\Documents and Settings\BDA Software\LienWaiver.doc"
  5. Dim wd As Word.Document
  6. Set wd = wdApp.Documents.Open(xPathDoc, , True)
  7. Dim wdMM As Word.MailMerge
  8. Set wdMM = wdApp.Documents(xPathDoc).MailMerge
  9. With wdMM
  10.     .MainDocumentType = wdFormLetters
  11.  
  12.         
  13.                     .OpenDataSource Name:="C:\Documents and Settings\BDA Software\Database.mdb", _
  14.     LinktoSource:=True, _
  15.     Connection:="TABLE tblLienWaiver", _
  16.     SQLStatement:="SELECT * from tblLienWaiver"
  17.  
  18.     .Destination = wdSendToPrinter
  19.     .SuppressBlankLines = False
  20.     With .DataSource
  21.         .FirstRecord = wdDefaultFirstRecord
  22.         .LastRecord = wdDefaultLastRecord
  23.         End With
  24.     .Execute 'Pause:=False
  25.     End With
Dec 10 '06 #3
NeoPa
32,569 Recognized Expert Moderator MVP
I don't know the correct syntax for this command, but I would guess the Connection parameter is wrong. Can you check Help for the correct syntax?
I would expect something like "TABLE=tblLienW aiver;" but I'm no expert in this.
Dec 10 '06 #4
Willis Wilson
3 New Member
I don't know the correct syntax for this command, but I would guess the Connection parameter is wrong. Can you check Help for the correct syntax?
I would expect something like "TABLE=tblLienW aiver;" but I'm no expert in this.
No, that is not the problem.
Dec 11 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2614
by: Tapi | last post by:
I have an ASP program that automatically sends text by email to customers. I would now like to improve it so that I can collect all the email text in a mail merge document and have the possibility of it by post. What's the best solution to mailmerge such info in ASP? TJ
2
3300
by: Nicolae Fieraru | last post by:
Hi All, I have a table in the database and a Word document saved on the hard disk. I want to mailmerge the content of the table into the word document, all done in vba. Any examples? I tried this:
0
1398
by: Anne Richmond | last post by:
I have a Word(2000) mailmerge routine (code below) which works OK but always names the merged document "Forml Letters1". How do I change this to something else? Also how do I automatically save the merged document to a specific destination? Dim wrdApp As Word.Application Dim wrdDoc As Word._Document
2
3374
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to confirm that I want to run a query to select the data from the data source file, then it opens the form letter fine. I can preview the merged records and complete a merge to a new document. I have a VB 2006 project (.net framework 2.0) which opens the...
0
1284
by: bobh | last post by:
Hi All, I have this older code(see below) that I used for a mailmerge in another application, I'm looking to do something similar but a little different in that, this time I have a single record to merge and after the merge to the document I want to store it on a particular server in a particular folder with a particular file name and I don't know what the coding would be for that. I assume it would go in place of the...
3
2554
prn
by: prn | last post by:
Hi folks, I'm trying to create letters based on an Access database. I'm using Access 2003 and Word 2003. Most of the data tables are actually on a SQL server and Access is the front end for them. I have the boilerplate for my letter ready. Now, with Access open and connected to the SQL server, I open Word with the file I want, click "Tools", "Letters and Mailings" and select MailMerge. Word allows me to select the document type, with...
2
5646
by: akaess | last post by:
Hey everybody I am currently trying to merger data from a form in MS access but it keeps giving me the error 91: Object variable or with block variable not set. could somebody please look at the code below and please guide me to a solution. Thank you! '**************************************************************** 'MailMerge method opens specified Word document and merges fields 'specified within the document with the Access fields...
0
1292
by: YY | last post by:
For some reason my word mail merge throws execption when it reaches wrdMailMerge = oDataDoc.MailMerge. Can any body guide me in a clean wasy of doing mailerge from sql server 2005 table ? I really appreciate your help. Below is the code I tried hundred times but throws exception. try {
1
2343
by: damezumari | last post by:
I use MS Office 2003 and would like to run several Word mail merges from Access. My code so far is given below. 1. The code does not do what I want. I want to save the new document with the merge result, not the merge template I start out with. At the moment it saves the latter. 2. I would like all Word documents to be closed in the end.
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.