Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
 
Posts: n/a
Default Access to word Mail merge problem: Requested object is not available

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

This has been cross posted from: comp.databases.ms-access

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default Access to word Mail merge problem: Requested object is not available

I assume from your code that you are manually attaching the datasource to
the mailmerge main document.

That being the case, from the Tools menu in Word, select Options and then go
to the General tab and check the box against "Confirm conversions at open."
After you do this, when you attach the data source to the mail merge main
document, you will be given a number of options for the method by which the
connection should be made. Selecting the DDE option will probably overcome
your
problem.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

wrote in message
oups.com...
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

This has been cross posted from: comp.databases.ms-access



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Access to word Mail merge problem: Requested object is not available

In this case, you probably need to read the following knowledgebase article
even though the title may not seem related to your problem.

"Opening This Will Run the Following SQL Command" Message When You Open a
Word
Document - 825765
http://support.microsoft.com?kbid=825765

Peter Jamieson
wrote in message
oups.com...
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

This has been cross posted from: comp.databases.ms-access



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 97 in Windows XP to maintain formatting Charlie''s Word VBA questions Microsoft Word Help 22 May 20th 23 08:51 PM
Embed tables from Access dynamically into Word mail merge letters? Thomas Staudte Mailmerge 8 December 13th 05 05:35 AM
Date problem with mail merge Word 2002 Andy Davis Mailmerge 3 June 22nd 05 09:43 AM
New problem - merge Word 2002 and Access 2002 par query Brad Hays Mailmerge 1 June 1st 05 11:52 AM
mail merge - Access 2000 and Word 2000 DawnMKA Mailmerge 1 March 26th 05 11:20 AM


All times are GMT +1. The time now is 12:26 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"