MailMerge Problems - Help Need

wavp

Registered User.
Local time
Today, 15:19
Joined
Apr 18, 2003
Messages
19
I have started having problems with MailMerge in my database - it has worked before but now I get this error:

Runtime error 5922

"Word was unable to open data source"

Here is my code:

Code:
Function MailMerge(strMMTemplate As String)
Dim objWord As Word.Application
Dim objDoc As Word.Document

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(fldMailmerge & strMMTemplate)

    'Make Word visible.
    objWord.Application.Visible = True
    'Set the mail merge data source
    objDoc.MailMerge.OpenDataSource Name:="C:\cmos\cmos.mdb", LinkToSource:=True, Connection:="TABLE tblMailMerge_Temp_Full", SQLStatement:="SELECT * FROM tblMailMerge_Temp_Full"
    'Execute the mail merge.
    objDoc.MailMerge.Execute
        objDoc.Close
        
Set objWord = Nothing
Set objDoc = Nothing
End Function

I have searched high an low through the forum and web - but no luck.

Any ideas? I am running Access 2003.

Cheers

Will
 
Is there anyone who can help me on my Mail Merge problem???
Does anyone else have this issue with Mail Merge (Access 2003) ???

Cheers

Will
 
Last edited:
The problem will be to find out WHY it won't open the data source. A possibility is that for some reason you have opened the .MDB file with OpenExclusive, which is not normally a good thing. Word needs to ALSO open the file, but with OpenExclusive it is possible for you to lock yourself out.

Have you been mucking about in the .MDW file lately? Or your permissions?
 
The_Doc_Man said:
The problem will be to find out WHY it won't open the data source. A possibility is that for some reason you have opened the .MDB file with OpenExclusive, which is not normally a good thing. Word needs to ALSO open the file, but with OpenExclusive it is possible for you to lock yourself out.

Have you been mucking about in the .MDW file lately? Or your permissions?

To answer your questions:

1) Have you been mucking about in the .MDW file lately?

No I havnt

2) Or your permissions?

No aswell

I have moved a step closer in solving my problem, what I did was to add "OpenExclusive:=True" to my string, see below:

Code:
objDoc.MailMerge.OpenDataSource Name:="C:\cmos\tmp_data.mdb", LinkToSource:=True, Connection:="TABLE tblMailMerge_Temp_Full", SQLStatement:="SELECT * FROM tblMailMerge_Temp_Full,[b]OpenExclusive:=True[/b]"

This does work, however when it loads word it asks me to select a table, is it possible to surpress this and automatically select the table?? I thought this statement in the string did that, Connection:="TABLE tblMailMerge_Temp_Full"

Thanks earlier for your direction.
 
Last edited:
Hi

Well I had the same problem. This is what I stumbled across, and it still works for me.

Open your .doc or .dot file by double clicking it. Say no to the proposed merging of data.
Save your template (the .doc or .dot file) after you have said no to the merging. And now in your application add something like.

oDoc.Close SaveChanges:=False 'closes the template without a save
'if u let it save the next time it will prompt you for the table to merge

where oDoc is of type Word.Document.

It works for me and should work for u 2...

grtz JB
 

Users who are viewing this thread

Back
Top Bottom