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)
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)