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
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
--
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
"Mike Molyneaux" <anon...@discussions.microsoft.com> wrote in message
news:12ec001c4436e$60704310$a401...@phx.gbl...
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.
>
>
> 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
>
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 :-)
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.
--
gene