Error 462 problem.

R

Roger Spencelayh

I've written an Access 2000 app which creates some Word documents. There
is one place that it errors randomly on error 462 - The remote server
machine does not exist or is unavailable. To give an idea as to the
randomness, I ran it over 100 times yesterday on one PC (Win 2000 + Office
2000) and it never failed. On another machine running Win XP + Office XP
Standard + Access 2000, it fails about 80% of the time. On a 3rd PC,
identical to the 2nd, it fails less than 10% of the time.

And on any PC, if you step through the code, it never fails.

The pertinent parts of the code follows, with the point where it fails
indicated thus: ----->

Note that some code has been omitted for clarity/brevity.

----------------------------------------------------------------------

Dim objWord As Word.Application

Set objWord = GetObject(, "Word.Application")

objWord.Documents.Add Application.CurrentProject.Path & _
cStrWordTemplate

'----------------------------------------------------------------------
' Put in the header
'----------------------------------------------------------------------

With objWord

' .ScreenUpdating = False
' .Visible = False
.Selection.Goto What:=wdGoToBookmark, Name:="bkShopType"
.Selection.TypeText Text:=strShopType
.Selection.MoveRight unit:=wdCell, Count:=2
.Selection.TypeText Text:="Dealer " & _
rst.Fields("DealerID") & _
" - " & rst.Fields("Dealer Name")
.Selection.MoveRight unit:=wdCell
.Selection.TypeText Text:=strWave
.Selection.EndKey unit:=wdStory
.Selection.TypeParagraph

'----------------------------------------------------------------------
' Loop through the recordset and find all the questions where
' points were lost
'----------------------------------------------------------------------

Do While Not rst.EOF
If rst.Fields("PointsScored") < _
rst.Fields("PointsAvailable") Then

'----------------------------------------------------------------------
' Create the table to hold the data
'----------------------------------------------------------------------

.Selection.EndKey unit:=wdStory
.Selection.TypeParagraph
.ActiveDocument.Tables.Add Range:=.Selection.Range, _
NumRows:=1, NumColumns:=1, _
DefaultTableBehavior:=wdWord9TableBehavior, _
AutoFitBehavior:=wdAutoFitFixed

-----> Fails between here and the next 3 lines

.Selection.Tables(1).PreferredWidthType = _
wdPreferredWidthPoints
.Selection.Tables(1).PreferredWidth = _
CentimetersToPoints(19.5)
.Selection.Rows.HeightRule = wdRowHeightAtLeast
.Selection.Rows.Height = CentimetersToPoints(1)
 
J

JB

Roger said:
I've written an Access 2000 app which creates some Word documents. There
is one place that it errors randomly on error 462 - The remote server
machine does not exist or is unavailable. To give an idea as to the
randomness, I ran it over 100 times yesterday on one PC (Win 2000 + Office
2000) and it never failed. On another machine running Win XP + Office XP
Standard + Access 2000, it fails about 80% of the time. On a 3rd PC,
identical to the 2nd, it fails less than 10% of the time.

And on any PC, if you step through the code, it never fails.

The pertinent parts of the code follows, with the point where it fails
indicated thus: ----->

Note that some code has been omitted for clarity/brevity.

----------------------------------------------------------------------

Dim objWord As Word.Application

Set objWord = GetObject(, "Word.Application")

objWord.Documents.Add Application.CurrentProject.Path & _
cStrWordTemplate

'----------------------------------------------------------------------
' Put in the header
'----------------------------------------------------------------------

With objWord

' .ScreenUpdating = False
' .Visible = False
.Selection.Goto What:=wdGoToBookmark, Name:="bkShopType"
.Selection.TypeText Text:=strShopType
.Selection.MoveRight unit:=wdCell, Count:=2
.Selection.TypeText Text:="Dealer " & _
rst.Fields("DealerID") & _
" - " & rst.Fields("Dealer Name")
.Selection.MoveRight unit:=wdCell
.Selection.TypeText Text:=strWave
.Selection.EndKey unit:=wdStory
.Selection.TypeParagraph

'----------------------------------------------------------------------
' Loop through the recordset and find all the questions where
' points were lost
'----------------------------------------------------------------------

Do While Not rst.EOF
If rst.Fields("PointsScored") < _
rst.Fields("PointsAvailable") Then

'----------------------------------------------------------------------
' Create the table to hold the data
'----------------------------------------------------------------------

.Selection.EndKey unit:=wdStory
.Selection.TypeParagraph
.ActiveDocument.Tables.Add Range:=.Selection.Range, _
NumRows:=1, NumColumns:=1, _
DefaultTableBehavior:=wdWord9TableBehavior, _
AutoFitBehavior:=wdAutoFitFixed

-----> Fails between here and the next 3 lines

.Selection.Tables(1).PreferredWidthType = _
wdPreferredWidthPoints
.Selection.Tables(1).PreferredWidth = _
CentimetersToPoints(19.5)
.Selection.Rows.HeightRule = wdRowHeightAtLeast
.Selection.Rows.Height = CentimetersToPoints(1)
You have a reference to DefaultTableBehavior:=wdWord9TableBehavior,
which may or may not be relevant.

Cheers

J
 
J

JB

Roger said:
I've written an Access 2000 app which creates some Word documents. There
is one place that it errors randomly on error 462 - The remote server
machine does not exist or is unavailable. To give an idea as to the
randomness, I ran it over 100 times yesterday on one PC (Win 2000 + Office
2000) and it never failed. On another machine running Win XP + Office XP
Standard + Access 2000, it fails about 80% of the time. On a 3rd PC,
identical to the 2nd, it fails less than 10% of the time.

And on any PC, if you step through the code, it never fails.

The pertinent parts of the code follows, with the point where it fails
indicated thus: ----->

Note that some code has been omitted for clarity/brevity.

----------------------------------------------------------------------

Dim objWord As Word.Application

Set objWord = GetObject(, "Word.Application")

objWord.Documents.Add Application.CurrentProject.Path & _
cStrWordTemplate

'----------------------------------------------------------------------
' Put in the header
'----------------------------------------------------------------------

With objWord

' .ScreenUpdating = False
' .Visible = False
.Selection.Goto What:=wdGoToBookmark, Name:="bkShopType"
.Selection.TypeText Text:=strShopType
.Selection.MoveRight unit:=wdCell, Count:=2
.Selection.TypeText Text:="Dealer " & _
rst.Fields("DealerID") & _
" - " & rst.Fields("Dealer Name")
.Selection.MoveRight unit:=wdCell
.Selection.TypeText Text:=strWave
.Selection.EndKey unit:=wdStory
.Selection.TypeParagraph

'----------------------------------------------------------------------
' Loop through the recordset and find all the questions where
' points were lost
'----------------------------------------------------------------------

Do While Not rst.EOF
If rst.Fields("PointsScored") < _
rst.Fields("PointsAvailable") Then

'----------------------------------------------------------------------
' Create the table to hold the data
'----------------------------------------------------------------------

.Selection.EndKey unit:=wdStory
.Selection.TypeParagraph
.ActiveDocument.Tables.Add Range:=.Selection.Range, _
NumRows:=1, NumColumns:=1, _
DefaultTableBehavior:=wdWord9TableBehavior, _
AutoFitBehavior:=wdAutoFitFixed

-----> Fails between here and the next 3 lines

.Selection.Tables(1).PreferredWidthType = _
wdPreferredWidthPoints
.Selection.Tables(1).PreferredWidth = _
CentimetersToPoints(19.5)
.Selection.Rows.HeightRule = wdRowHeightAtLeast
.Selection.Rows.Height = CentimetersToPoints(1)
Forgot to say that Office XP is Office10, Office 2003 is Office11
 
R

Roger Spencelayh

You have a reference to DefaultTableBehavior:=wdWord9TableBehavior,
which may or may not be relevant.

Sorry, should have made it clear, it does fail on Word 2000 as well.
 

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