By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

Access to word Mail merge problem: Requested object is not available

P: n/a
I have a problem with a mail merge procedure I used to use with Access
'97.

We recently converted to Office XP (2002) and I now have an issue I am
unfamilliar with and have been unable to resolve.

I am trying to merge individual records into seperate mail merge word
docs. In the past I linked my word files directly to the tables and
then simply changed the QueryString of the merge file for the
particular record I need to create a file for.

Here is a sample of the code I used in the past.
************************************************** *****************
Private Sub Command0_Click()

Dim w As Word.Application
Dim m As MailMerge
Dim mm As MailMergeDataSource
Dim d As Word.Document
Dim rst1 As dao.Recordset

Set rst1 = CurrentDb.OpenRecordset("tblMergeData")

Do Until rst1.EOF
Set w = New Word.Application
w.Visible = True
Set d = w.Documents.Open("H:\My Documents\MyLetter.doc")
Set m = d.MailMerge
Set mm = d.MailMerge.DataSource

'I Get the error
'[ Run Time Error '5852':
'Requested object is not available ]
'on the next line. This code was not a problem in Office '97

mm.QueryString = "SELECT * FROM tblMergeData WHERE MergeF1 = '"
& rst1!myfield & "'"

m.Execute
Set mm = Nothing
Set m = Nothing
d.Close wdDoNotSaveChanges
Set d = w.Documents("Form Letters1")
d.SaveAs ("H:\My Documents\MyLetter" & rst1!Myfield1 & ".doc")
d.Close
w.Quit
Set w = Nothing
rst1.MoveNext
Loop

End Sub

************************************************** *************

Please note, I do realise I could change the source of my mail merge
file to a query and just change the SQL of my Query, however I have
several documents that use this method and would like to preserve the
process if at all possible.

I appreciate any thoughts.

Mike

May 8 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.