Mail Merge - Word was unable to open the datasource 
Author Message
 Mail Merge - Word was unable to open the datasource

I have written an application using Access 2000.  It
includes a mail merge facility which I have implemented
using late binding.  I have used late binding because I
have no control of what is implemented on a user's machine
and would like the program to function with Word 97, Word
2000 and Word XP.

The mail merge feature works in a run time environment
with Word 2000 and Word XP but the same program errors on
a Win 98 machine with Word 97 installed.  The error I am
receiving is:
   Err Number = 5922
   Word is unable to open the datasource

I tried connecting to the datasource directly from Word
and received the following error:
   This program is not set to run in MS-DOS mode and
   cannot run while ohter programs are running.  All
   other programs will close if you choose to continue.

   Choosing the continuation options does not do anything.

I don't know whether the above error has any bearing on
the message I am receiving from my application (Error
5922).

This is a copy of the code:

   ' Get/Create an instance of Microsoft Word.
    bnIsRunning = True
    bnCreateWord = False
    Set WordApp = GetObject(, "Word.Application")

    If bnCreateWord = True Then
        Set WordApp = CreateObject("Word.Application")
    End If

    ' Create a new, empty document.
    Set WordDoc = WordApp.Documents.Add
    With WordDoc.mailmerge
        If UseDDE Then
            strConnect = "tblCustomer"
        Else
            ' Path to database.

            strConnect = "DSN=MS Access " _
                    & "Database;DBQ=" & CurrentDb.Name _
                    & ";" _
                    & "FIL=MS Access;"
        End If

        ' Path to database.
        .OpenDataSource _
        Name:=CurrentDb.Name, _
            ReadOnly:=True, LinkToSource:=True, _
            Connection:=strConnect, _
            SQLStatement:="SELECT * FROM [tblMailMerge]"
    End With

    With WordDoc.mailmerge

        ' Merge the data to a new document.
        '.Destination = wdSendToNewDocument
        .Destination = 0    ' 0 (zero) = new document

        ' Execute the mail merge.
        '.Execute

        ' If user specified to print the document, disable
        ' background printing, and then print the merged
document.
        If PrintDoc Then
            .Application.Options.PrintBackground = False
            .Application.ActiveDocument.PrintOut
        End If
    End With

    ' Show the instance of Microsoft Word.
    WordApp.Visible = True

CreateMergeDocError:
    Select Case Err.Number
        Case 429
            If bnCreateWord = False Then   ' Word is not
running, attempt to create object
                bnIsRunning = False
                bnCreateWord = True
                Resume Next
            Else
                intReturn = MsgBox("Mail Merge: Error " &
Str(Err.Number) & " " & Err.Description, vbInformation,
glAppname)

            End If
        Case Is <> 0
            intReturn = MsgBox("Mail Merge: Error " & Str
(Err.Number) & " " & Err.Description, vbInformation,
glAppname)
    End Select

Any help will be most appreciated.

CR



Sat, 15 Oct 2005 12:18:06 GMT  
 Mail Merge - Word was unable to open the datasource
The problem is often that the data source tries to use the wrong version of
office.

I would not all try and let word somehow load, attach, and figure out what
version of access it should use. If you have a mixed version of office, then
word has no way of know what version of ms-access to launch. Further, there
is a bug where multiple copies of ms-access get launched when the name of
your ms-access application is changed (from Microsoft Access).

Worse, you get problems when you implement security, and have to deal with
passwords. This becomes an even greater mess when versions of office are
mixed again.

The solution here is to NOT connect to ms-access.

I have a real slick mail merge code. To word enable ANY form, you just need
ONE LINE of code behind the button on the form, and the rest is 100%
automatic.

Give it a try, is about as slick as you can get:

It is in my downloads section:

http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html

There is sample form that shows how simple this whole thing is.

--
Albert D. Kallal
Edmonton,  Alberta Canada

http://www.attcanada.net/~kallal.msn



Sat, 15 Oct 2005 13:43:27 GMT  
 Mail Merge - Word was unable to open the datasource
Thanks Albert for your comments.

What you are saying certainly makes sense and I can see
how your solution could resolve all such issues.

I am however still a bit confused by the inconsistent
results that I have been getting ie:

I conducted further tests on two other machines both
running Win 98 with similar profiles (Access 2000 RT and
Word 97) mail merge worked perfectly.

I re-installed Word 97 on the original machine but my
application still came up with the same error (5922 Word
was unable to open the datasource).  Re-installing office
didnt make any difference.

On machines with similar software installed, can Word not
consistently use the wrong (or correct) version of Access?

In terms of your solution, are you aware of any
limitations with text files (eg size) that would prohibit
the merge from working as expected?

CR

Quote:
>-----Original Message-----
>The problem is often that the data source tries to use

the wrong version of
Quote:
>office.

>I would not all try and let word somehow load, attach,
and figure out what
>version of access it should use. If you have a mixed

version of office, then
Quote:
>word has no way of know what version of ms-access to

launch. Further, there
Quote:
>is a bug where multiple copies of ms-access get launched
when the name of
>your ms-access application is changed (from Microsoft
Access).

>Worse, you get problems when you implement security, and
have to deal with
>passwords. This becomes an even greater mess when

versions of office are
Quote:
>mixed again.

>The solution here is to NOT connect to ms-access.

>I have a real slick mail merge code. To word enable ANY
form, you just need
>ONE LINE of code behind the button on the form, and the
rest is 100%
>automatic.

>Give it a try, is about as slick as you can get:

>It is in my downloads section:

>http://www.attcanada.net/~kallal.msn/msaccess/msaccess.htm
l

>There is sample form that shows how simple this whole
thing is.

>--
>Albert D. Kallal
>Edmonton,  Alberta Canada

>http://www.attcanada.net/~kallal.msn

>.



Sat, 15 Oct 2005 16:51:29 GMT  
 Mail Merge - Word was unable to open the datasource
Not aware of any file size problems.

However, the problem of word knowing what version of access to launch is a
problem.

I would try manually making a mail merge from Word to ms-access on those
pc's that don't work, and see if that works. There is no use trying some of
your code if you can't even get Word to do a mail merge manually. I guess
the question is does mail merge work at all on those bad pc's, or just your
code not working?

--
Albert D. Kallal
Edmonton,  Alberta Canada

http://www.attcanada.net/~kallal.msn



Sun, 16 Oct 2005 01:40:01 GMT  
 Mail Merge - Word was unable to open the datasource
Connection to the datasource from word is no-longer a
problem.  The error I was getting earlier ie:
   This program is not set to run in MS-DOS mode and
   cannot run while other programs are running.

was solved by clearing the ms-dos checkbox property for
the command.pif file (don't know why it was set that way
but the solution described in Microsoft Knowledge Base
Article - 197774 worked).

Unfortunately I am still getting error 5922 Word was
unable to open the datasource in my application.

I have been thinking about your comment:
"However, the problem of word knowing what version of
access to launch is a problem"

Is this an issue if Access 2000 RT is already running and
the connection is established via my application and not
from Word?  Since Access is already executing, there is no
need for Word to launch Access.  It seems logical but is
this how it works?

The situation as it stands:
1) Word has not problems connecting to the datasource.
2) My application continues to fail with error 5922 Word
unable to open the datasource.

This problem has occurred on only one of my test machines,
all other machines with the same profile function
correctly.

This indicates to me either a code problem (can't
understand why it works on some machines though) or
something is corrupted on the 'bad' pc - may be I will
need to rebuild the machine.

I guess the reason for pursuing this is so that I can try
to understand the reasons for the problems.  I think
ultimately, I will take your advice and resort to your
solution.

CR

Quote:
>-----Original Message-----
>Not aware of any file size problems.

>However, the problem of word knowing what version of

access to launch is a
Quote:
>problem.

>I would try manually making a mail merge from Word to ms-
access on those
>pc's that don't work, and see if that works. There is no
use trying some of
>your code if you can't even get Word to do a mail merge
manually. I guess
>the question is does mail merge work at all on those bad
pc's, or just your
>code not working?

>--
>Albert D. Kallal
>Edmonton,  Alberta Canada

>http://www.attcanada.net/~kallal.msn

>.



Sun, 16 Oct 2005 09:37:26 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. MS Word 97 Mail Merge with Oracle Datasource?

2. MS Word 97 Mail Merge with Oracle Datasource?

3. Word Mail Merge Err - Word could not merge...

4. Opening a Mail merged Document from word

5. Formatting Merge Fields in Word Mail Merge

6. HTML forms, Word, e-mail and mail merge

7. QueryString length of mail merge datasource.

8. creating word mailing labels with Mail Merge

9. Macro for Mail Merge and Datasource...

10. HTML forms, Word, e-mail and mail merge

11. Mail merge from Access try to open an already open DB

12. Mail Merge BarCodes / Mail Merge Insertion Point

 

 
Powered by phpBB® Forum Software