mailmerge function not opening datasource

G

Guest

I am trying to do a mailmerge from Access and have written a post previously
about my problems, ive since partially solved those problems but have a new
related one.
I can do a mailmerge from word with no problem, associating with data from
access with no problem.
Im trying to do the same thing from a function in access but come up with a
'cannot open the datasource' problem after its opened the mailmerge document
but fails to merge it to the data from the datasource.
Debug points to the following function:
<!----

Function MergeIt()

Dim strConnection As String
Dim objWord As Word.Document

Set objWord = GetObject("\\sbserver\data\amit\Word
Documents\Agreement20051.doc", "Word.document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the forms
objWord.MailMerge.OpenDataSource Name:="\\sbserver\data\amit\Test
Database\Database1_te.mdb", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
Format:=0, _
Connection:="Query [Mergedata]", _
SQLStatement:="SELECT * FROM [Mergedata]", _
openExclusive:=False, subtype:=wdMergeSubTypeWord2000
' Execute the mail merge.
objWord.MailMerge.Execute

End Function

--->
can anyone spot anything strange with this? why wont it open the datasource?

With much thanks
Amit
 
G

Guest

I had a similar problem doing this same thing. I found that is was a problem
with the name of the source. Mine was named 2006-3-28, and i would get an
error could not open data source. Perhaps you should try to change the name
of the source to not include a space, like "test.mdb" then change the code
appropriately. If this does not work then you may try located the source in
another location a little higher up in a directory. Some time there are
issues with having to long of a file name. So put on the top level of the C
drive and then change the code appropiately and see if it works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top