Run-time error '5852'

M

Mo

The situation is as follows:

I get a 'runtime error 5852. Run-time error '5852'. Requested object is
not available' message when I use Access 2003 to send data to a word
(2003) mailmerge document.

Prior to going over to Office 2003 we have not had any problems with
this functionality.

So far I've tried the suggestions in these two MS articles:

http://support.microsoft.com/kb/913804/

http://support.microsoft.com/kb/825765/

So far neither of these have worked.

Anyone have any idea what else it could be and how to resolve this?

The VBA I'm using is MS standard:

If CreateWordObj() Then
With gobjWord
.Visible = True
.Documents.Open "C:\screening\template.doc"
DoEvents
With gobjWord.ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
.Execute
End With
.ActiveDocument.PrintPreview
.Visible = True
End With
End If

Thanks for any help,

Mo








----------------------------------------
Mohamed Joomun
Database Programmer, CEPM
Wolfson Institute of Preventive Medicine
Barts and The London
Queen Mary's School of Medicine and Dentistry
Charterhouse Square, London EC1M 6BQ, UK

Tel: +44 (0)20 7882 6265
Fax: +44 (0)20 7882 6270
E-mail: (e-mail address removed)
 
J

John Nurick

Hi Mo,

Set a breakpoint on the line
If CreateWordObj() Then
and then step through the code line by line. Exactly which line is
raising the error?
 
M

Mo

John said:
Hi Mo,

Set a breakpoint on the line
If CreateWordObj() Then
and then step through the code line by line. Exactly which line is
raising the error?

The error is raise on this line;

.Destination = wdSendToNewDocument

Any ideas?
 
M

Mo

OK John, it's sorted.

I recreated the word doc and everything works fine (fingers crossed).

Thanks for your help.

Mo
 
Joined
Aug 3, 2016
Messages
1
Reaction score
0
OK, I know I'm 10 years late for this thread, but I've been having runtime error 5852 for a long time, but at random. The situation is the following: I'm a translator and everyone now and then I need to compare documents and count the changes to prepare a quote. I'm using the following code I found online:

Sub GetTCStats()
Dim lInsertsWords As Long
Dim lInsertsChar As Long
Dim lDeletesWords As Long
Dim lDeletesChar As Long
Dim sTemp As String
Dim oRevision As Revision

lInsertsWords = 0
lInsertsChar = 0
lDeletesWords = 0
lDeletesChar = 0
For Each oRevision In ActiveDocument.Revisions
Select Case oRevision.Type
Case wdRevisionInsert
lInsertsChar = lInsertsChar + Len(oRevision.Range.Text)
lInsertsWords = lInsertsWords + oRevision.Range.Words.Count
Case wdRevisionDelete
lDeletesChar = lDeletesChar + Len(oRevision.Range.Text)
lDeletesWords = lDeletesWords + oRevision.Range.Words.Count
End Select
Next oRevision

sTemp = "Insertions" & vbCrLf
sTemp = sTemp & " Words: " & lInsertsWords & vbCrLf
sTemp = sTemp & " Characters: " & lInsertsChar & vbCrLf
sTemp = sTemp & "Deletions" & vbCrLf
sTemp = sTemp & " Words: " & lDeletesWords & vbCrLf
sTemp = sTemp & " Characters: " & lDeletesChar & vbCrLf
MsgBox sTemp
End Sub

This code sometimes works and sometimes it doesn't. For example, 10 minutes ago I was comparing documents (using word 2013) and counting the number of new words in each one. The first 4 times it worked perfectly. With the fifth document, I get this error. Nothing different than the other times, since the "compared" document is always a new document Word creates.
Any ideas? I would love for this to work everytime.

Many thanks.
 

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

Similar Threads

Run-time error '5852' 1

Top