Access 2003 and Word 2003 - bug or my error????

C

_Carolyn

I am doing a mail merge from Access and keep getting an error:
5852 Requested object is not available.

I did a search and found many people have this error and I dont see any
resolution. .Destination = wdSendToNewDocument 5852

Its Access 2003 calling Word 2003, in vba code.
It bombs out at -->.Destination = wdSendToNewDocument
Thank you,
Carolyn

-----code below------------

Sub DoLetter()
On Error GoTo errHandler

Dim oApp As Object
Set oApp = CreateObject("Word.Application")

oApp.Visible = True

oApp.Documents.Open FileName:="Conversion_ClientLetter1.doc",
ConfirmConversions _
:=False, ReadOnly:=True, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""


With oApp.ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
.LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
End With
.Execute Pause:=False
End With

DatabasePath.SetFocus
ChangeFileOpenDirectory DatabasePath.Text & "\"

oApp.ActiveDocument.SaveAs FileName:="Client Letter.doc", FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
oApp.ActiveDocument.PrintOut Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True,
PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
oApp.ActiveDocument.Close

oApp.Application.Quit
Set oApp = Nothing
Exit
 
D

Doug Robbins

Maybe the reference to ActiveDocument is not what you think it is to.

Instead of using ActiveDocument, declare a variable as a Document and set
that variable to the document that you are opening and then refer to that
variable.

Dim oApp As Object, oDoc As Document
Set oApp = CreateObject("Word.Application")

oApp.Visible = True

Set oDoc = oApp.Documents.Open(FileName:="Conversion_ClientLetter1.doc",
ConfirmConversions _
:=False, ReadOnly:=True, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto,
XMLTransform:="")

With oDoc.MailMerge
.Destination = wdSendToNewDocument
'etc.

End With

See if that overcomes the problem. But another thing to check for is if
there is actually a datasource attached to the document.

To see some code that I know does work, See the "Super easy Word merge" item
on fellow MVP Albert Kallal's website at
http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
M

Malcolm Smith

Carolyn

You should never use ActiveDocument as a pointer OUTSIDE of the Word
Application. Create your own pointer when you open the document and then
work with that.

Hope that this helps
- Malc
 

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