Running 2003 on xp pro.
have latest updates on both.
receive run-time error '5852':
requested object is not available.
code runs find on office 2000 & nt4, sp6
code:
with activeDocument.MailMerge
.Destination = wdSendToNewDocument 'Error on this line'
.SuppressBlankLines = False
with .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
end with
.execute Pause:=False
end with
code created by recording macro as doing the merge
the merge worked fine as I recorded macro.
now get vb error
any help greatly appreciated
Mike
Doug Robbins - Word MVP - 27 May 2004 07:06 GMT
You get that problem if the activedocument is not a mailmerge main document
or does not have a datasource attached to it. To prevent it from happening,
use:
If ActiveDocument.MailMerge.State = wdMainAndDataSource Then
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument 'Error on this line'
.SuppressBlankLines = False
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End If

Signature
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
> Running 2003 on xp pro.
> have latest updates on both.
[quoted text clipped - 24 lines]
>
> Mike
snareg - 04 Aug 2004 23:03 GMT
We run into the same error when doing a mail merge on XP Office but not on all XP Office installations.
Our app sets the references to Word and Office in the reference listing under tools instead of in code. The original was set to 9 on both of the refrences. I took the merger document onto an XP machine running at 10 on both Word and office in the refernces. I clicked off the reference to Office 10 and saved and closed the documents. Then I opened it again and let the code run. It ran fine with no errors.

Signature
gene
> You get that problem if the activedocument is not a mailmerge main document
> or does not have a datasource attached to it. To prevent it from happening,
[quoted text clipped - 40 lines]
> >
> > Mike
Cindy M -WordMVP- - 29 May 2004 16:57 GMT
Hi Mike,
Doug explains what's causing the error, but not why you're
getting it...
Are you opening these documents manually, or using VBA code?
If VBA code, then you're probably running into this:
"Opening This Will Run the Following SQL Command" Message
When You Open a Word Document - 825765
http://support.microsoft.com?kbid=825765
> Running 2003 on xp pro.
> have latest updates on both.
[quoted text clipped - 17 lines]
> end with
>
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)