Error 462: Server not available

A

Alex St-Pierre

Hi,
I execute a program from Excel that copy excel table into Word and format
the table thereafter. Sometimes (about 1 time on 3), the program stop at the
following line: .LeftIndent = CentimetersToPoints(0) (see program below)
The error message is: "Error 462": Server not available
After having an error, I can restart the macro and all works. I really don't
know what is the problem.
It seems to come with: With appWord.Selection.ParagraphFormat
The Word reference is open inside Excel (10.0) and there's no missing error.
Thanks a lot!
Alex

Dim appWord As Word.Application
Dim docWord2 As Word.Document
Dim oExcel As Object 'Excel.Application
Dim owb As Object 'Excel.Workbook
Dim oXlRng As Object 'Excel.Range
Dim tbl As Word.table

On Error Resume Next
Set appWord = GetObject(, "Word.Application")
If appWord Is Nothing Then
Set appWord = CreateObject("Word.Application")
End If
On Error GoTo 0
Set owb = oExcel.ActiveWorkBook

Set docWord2 = appWord.Documents.Add
Set oXlRng = owb.Sheets("abc").Range("TableOutput")
oXlRng.Copy
appWord.Selection.PasteExcelTable LinkedToExcel:=False,
WordFormatting:=False, RTF:=False
Set tbl = docWord2.Tables(1)
docWord2.Bookmarks(1).Delete
tbl.Select
appWord.Activate
With appWord.Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0) 'Error here
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 2
.SpaceBeforeAuto = False
.SpaceAfter = 2
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
End With
 
H

Helmut Weber

Hi Alex,

at a very long shot I'd say,
.LeftIndent = CentimetersToPoints(0) 'Error here
.RightIndent = CentimetersToPoints(0)

is prone to cause errors.

Try:

..LeftIndent = 0
..RightIndent = 0

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

Tony Jollans

The 'normal' explanation for this is disconnection of implicitly
instantiated objects. My first thought was that CentimetersToPoints was a
Word method and needed qualification but as it is also a method of Excel I
don't know. I would still be inclined to try qualifying it (either with
appWord or Application) to see if it made a difference.
 

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