Automation Error - RPC Server is unavailble.

L

Linda

I'm trying to automate a mailmerge process that should
create a new merged document and save it to C:\TEMP
For some reason I'm always getting the following error
message:

Automation Error - The RPC server is unavailable.

This is the routine:

Dim objWord As Object
Set objWord = CreateObject("Word.Application")
objWord.Application.Visible = True
objWord.Application.Documents.Open "\\serv01
\applications\MailMerges\OutstandingBill.doc"

With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
ChangeFileOpenDirectory "C:\TEMP\"
ActiveDocument.SaveAs
FileName:="outstandingbill.doc", FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="", AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False
Application.Quit
Set objWord = Nothing

ANY HELP IS MOST APPRECIATED!
 
L

Linda

I have changed the routine to this:

Set objWord = CreateObject("Word.Application")
objWord.Application.Visible = True
objWord.Application.Documents.Open "\\brussfmc1
\applications\JAS\FMC\MailMerges\Outstanding Bill.doc"

With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Execute
End With
ChangeFileOpenDirectory "C:\TEMP\"
ActiveDocument.SaveAs
FileName:="outstandingbill.doc", FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="", AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False
Application.Quit

The problem is that one still has to manually close the
merged document. I don't know why the routine is NOT
closing the document. Again any help is most appreciated.
 
G

Guest

I haven't tested this, but maybe it will help

1. Release the reference to Word at the end of the procedure i.e. "Set objWord = Nothing

2. If you still have trouble, would creating a new object variable (say objDoc for example) to hold reference to the actual document help? You could then say

objDoc.Clos
Set objDoc = Nothin
objWord.Qui
Set objWord = Nothin

Basil
 
L

Linda

Thanks I will try that.
-----Original Message-----
I haven't tested this, but maybe it will help:

1. Release the reference to Word at the end of the
procedure i.e. "Set objWord = Nothing"
2. If you still have trouble, would creating a new
object variable (say objDoc for example) to hold
reference to the actual document help? You could then say:
 

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