473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Error 5922 when opening a mailmerge document in Word

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.Application, wd As Word.Document, strConnection As String
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = False
xPathDoc = "C:\Documents and Settings\BDA Software\LienWaiver.doc"
Set wd = wdApp.Documents.Open(xPathDoc, , True)
Dim wdMM As Word.MailMerge, strSourceFile As String
Set wdMM = wdApp.Documents(xPathDoc).MailMerge
With wdMM
.MainDocumentType = wdFormLetters
.OpenDataSource Name:="C:\Documents and Settings\BDA Software\Database.mdb", _
LinkToSource:=True, _
Connection:="TABLE tblLienWaiver", _
Sqlstatement:="SELECT * from tblLienWaiver"
.Destination = wdSendToPrinter
.SuppressBlankLines = False
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute 'Pause:=False
End With

Set wdMM = Nothing
wd.Close wdDoNotSaveChanges
wdApp.Quit
Set wdApp = Nothing
Exit Sub
' *********************************
Thank you, Willis
Nov 27 '06 #1
4 7718
NeoPa
32,556 Expert Mod 16PB
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,

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,556 Expert Mod 16PB
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=tblLienWaiver;" but I'm no expert in this.
Dec 10 '06 #4
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=tblLienWaiver;" 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
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...
2
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...
0
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...
2
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...
0
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...
3
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....
2
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...
0
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.