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

G

Guest

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

I did a search on google 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 Sub
 
B

Brendan Reynolds

You appear to be using late binding, which implies that you don't have a
reference to the Word object library. This is a useful technique to avoid
errors if your app is run on a PC with a different version of Word
installed, but it means that you can not use intrinsic constants, such as
wdSendToNewDocument, that are defined in the Word object library. You need
to use the numeric value of the constant instead, or better, define your own
constants with the numeric values, and use those constants in your code ...

Public Const lngcSendToNewDocument = 0
....
..Destination = lngcSendToNewDocument

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

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