Word routine run a second time creates '462' Error

E

Edward Harford

I am opening Word Document from Access Form command button and filling word table with data
Creating Word object and filling table with data from recordset works fine on the first click. But the second time comes up with Run-time error '462' - "The remote server machine does not exist or is unavailable" at the point where I am setting table-column width see * below

Dim docWord As Word.Documen
Dim appWord As Word.Applicatio
Dim wRng As Word.Range, wTbl As Word.Tabl
Dim iRow As Integer, iRecs As Intege
Dim wArr() As wTable, T As Integer 'wTable is UDT

Set appWord = CreateObject("Word.Application.11"
Set docWord = appWord.Documents.Add(strFinalDoc
appWord.Visible = Tru

[Code that fills wArr

Set wRng = docWord.Characters.Las
wRng.Collaps
Set wTbl = docWord.Tables.Add(Range:=wRng, NumRows:=UBound(wArr) + 1, NumColumns:=2
* wTbl.Columns(1).SetWidth ColumnWidth:=InchesToPoints(1), RulerStyle:=wdAdjustNon
wTbl.Columns(2).SetWidth ColumnWidth:=InchesToPoints(5.5), RulerStyle:=wdAdjustNon
 
D

David Mann

Edward Harford said:
I am opening Word Document from Access Form command button and filling word table with data.
Creating Word object and filling table with data from recordset works fine
on the first click. But the second time comes up with Run-time error '462' -
"The remote server machine does not exist or is unavailable" at the point
where I am setting table-column width see * below.
Dim docWord As Word.Document
Dim appWord As Word.Application
Dim wRng As Word.Range, wTbl As Word.Table
Dim iRow As Integer, iRecs As Integer
Dim wArr() As wTable, T As Integer 'wTable is UDT'

Set appWord = CreateObject("Word.Application.11")
Set docWord = appWord.Documents.Add(strFinalDoc)
appWord.Visible = True

[Code that fills wArr]

Set wRng = docWord.Characters.Last
wRng.Collapse
Set wTbl = docWord.Tables.Add(Range:=wRng, NumRows:=UBound(wArr) + 1, NumColumns:=2)
* wTbl.Columns(1).SetWidth ColumnWidth:=InchesToPoints(1), RulerStyle:=wdAdjustNone
wTbl.Columns(2).SetWidth ColumnWidth:=InchesToPoints(5.5), RulerStyle:=wdAdjustNone

First, are you sure the error code is '462', as this does not seem to be
defined - I expect someone will find it now!

Second, is the table 'regular', or have you merged some cells, so that the
'columns' are no longer meaningful, so that 'wTbl.Columns(..)' fails?

And a question - can you explain what "Word.Application.11" means, as this
fails on my system, whereas 'Set appWord = CreateObject("Word.Application")'
runs fine - are you defining the version of Word?

David
 
E

Edward Harford

Davi
Thanks for coming back to me. I have solved the problem - there seems to be a problem with InchestoPoints function on the second run. If I set height and width to a literal i.e. points it works fine. As to Word.Application.11 - this refers to version. I am just being specific.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RWR3YXJkIEhhcmZvcmQ=?=,
I have solved the problem - there seems to be a problem with InchestoPoints function on the second run. If I set height and width to a literal i.e. points it works fine. As to Word.Application.11 - this refers to version. I am just being specific.
The true problem is that Word-specific functions, such as InchesToPoints, must be correctly qualified in order to workcorrectly. For xample:

appWord.InchesToPoints(1)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :)
 

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