Creating MailMerge in Word from Access

G

Guest

I'm getting the following run-time error '-2147023174 (800706ba)'
Automation error, The RPC Server is unavailable

only about 50% of the time I run a Function that creates a Letter in Word
containing fields from Access, such as recipient address, subject matter etc.

I've tried different suggestions including a workaround in an MS article
about this error, but that's not working either. Any suggestions please? The
deadline for this is tomorrow and I desperately want to get it done.

Here are the first few lines and where the code breaks...

Function CreateInsLetter(icID As Integer)
Dim wdApp As Object, wdDoc As Object

Set wdApp = New Word.Application
Set wdDoc = New Word.Document
With wdDoc.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.LeftMargin = CentimetersToPoints(2.54) 'Breaks Here
 
G

Guest

Calvin said:
I'm getting the following run-time error '-2147023174 (800706ba)'
Automation error, The RPC Server is unavailable

only about 50% of the time I run a Function that creates a Letter in Word
containing fields from Access, such as recipient address, subject matter etc.

I've tried different suggestions including a workaround in an MS article
about this error, but that's not working either. Any suggestions please? The
deadline for this is tomorrow and I desperately want to get it done.

Here are the first few lines and where the code breaks...

Function CreateInsLetter(icID As Integer)
Dim wdApp As Object, wdDoc As Object

Set wdApp = New Word.Application
Set wdDoc = New Word.Document
With wdDoc.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.LeftMargin = CentimetersToPoints(2.54) 'Breaks Here


I've had the same problem opening Word from Excel, drawing a table, and then
re-sizing it. The code breaks where I try to re-size the table column which
seems to be a similar situation. As with you, this only happens sometimes &
there are no synatx or logical errors in the code. As a quick fix if you can
get away without re-sizig the margin, it might help. For info - here's the
code I'm using:

Sub Contents_to_Word()

Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document

' Open Word
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True

' add new doc
Set wrdDoc = wrdApp.Documents.Add

' draw table
wrdDoc.Tables.Add Range:=wrdDoc.Range(Start:=0, End:=0), NumRows:=31,
NumColumns:=2

wrdDoc.Tables(1).Columns(1).SetWidth
ColumnWidth:=CentimetersToPoints(5), RulerStyle _
:=wdAdjustNone ' Breaks here
 

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