Error in Word from Access

S

SHIPP

I am getting the following error every 2nd time I run the code below.

Runtime Error 462

The remote server machine does not exist or is unavailable.

It is strange. I am not using a remote server. And it happens exactly every
second time I run the code.

The error occurs at the line.

With ActiveDocument.PageSetup

Help, Please.


Public Sub sWordXport(strSaveTo As String)


'***************************************************************************************
'* PROGRAM : TRN
'* CREATED : 8/5/08
'* COMMENTS : Validates the current record
'* PARAMETERS: -
'* RETURNS : Boolean -
'* CALLED BY :
'* MODIFIED :

'***************************************************************************************

On Error GoTo HandleErr
Const cstrProcName As String = "modCDOEmail - sWordXport"

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim fld As Field
Dim strHdr As String
Dim strUnique As String

Dim objWord As Word.Application
Dim wDoc As Word.Document

' Set objWord = CreateObject("Word.Application")
' Set objWord = New Word.Application
' objWord.Documents.Add
' Set doc = objWord.ActiveDocument
' objWord.Visible = True

Set objWord = CreateObject("Word.Application")
' Set objWord = GetObject(, "Word.Application")
objWord.Documents.Add
' Set doc = objWord.ActiveDocument
objWord.Visible = True

Set db = CurrentDb()
Set rs = db.OpenRecordset("qryWordExport")

With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
' Create Header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.TypeText Text:="CONTRA COSTA SUPERIOR COURT"
Selection.TypeParagraph
Selection.TypeText Text:="MARTINEZ, CALIFORNIA"
Selection.TypeParagraph
Selection.TypeText Text:="DEPARTMENT: " & GetDept()
Selection.TypeParagraph
Selection.TypeText Text:="HEARING DATE: " & GetDateBeg()
Selection.WholeStory
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Font.Size = 14
Selection.Font.Name = "Arial"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument



' Create table
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=20, NumColumns _
:=4, DefaultTableBehavior:=wdWord9TableBehavior ', AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = InchesToPoints(0.1)
Selection.SelectCell
Selection.TypeText Text:="H"
Selection.MoveRight Unit:=wdCell
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = InchesToPoints(0.1)
Selection.SelectCell
Selection.TypeText Text:="S"
Selection.MoveRight Unit:=wdCell
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = InchesToPoints(0.1)
Selection.SelectCell
Selection.TypeText Text:="T"
Selection.MoveRight Unit:=wdCell
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = InchesToPoints(6.7)
Selection.SelectCell
Selection.TypeText Text:="TENTATIVE RULING"

' Create the data
rs.MoveLast
rs.MoveFirst
' Create the first Header
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="C"
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
strHdr = rs("UniqueIdnt") & "." & "TIME: " & rs("TrnTime") & "CASE #" &
rs("CaseNo")
strHdr = strHdr & vbCr & "CASE NAME: " & rs("TrnName") & vbCr
strHdr = strHdr & rs("TrnDesc1")
Selection.TypeText Text:=strHdr
Selection.SelectCell
Selection.Font.Name = "Arial"
Selection.Font.Bold = wdToggle
While Not rs.EOF
strUnique = rs("UniqueIdnt")
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("TrnHdr")) Or Trim(rs("TrnHdr")) <> "" Then
Selection.TypeText Text:="H"
Else
Selection.TypeText Text:="D"
End If
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("sTrnID")) Then
Selection.TypeText Text:=rs("sTrnID")
End If
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("TrnID")) Then
Selection.TypeText Text:=rs("TrnID")
End If
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("TrnHdr")) Or Trim(rs("TrnHdr")) <> "" Then
Selection.TypeText Text:=rs("TrnHdr")
Selection.SelectCell
Selection.Font.Name = "Arial"
Selection.Font.Italic = wdToggle
Selection.Font.Bold = wdToggle
' If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
' Else
' Selection.Font.Underline = wdUnderlineNone
' End If
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 12
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
End If
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("TrnDtl")) Or Trim(rs("TrnDtl")) <> "" Then
Selection.TypeText Text:="D"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=rs("sTrnID")
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=rs("TrnID")
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=rs("TrnDtl")
Selection.SelectCell
Selection.Font.Name = "Arial"
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.2)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
Else
Selection.MoveLeft Unit:=wdCell
End If
rs.MoveNext
' Create the next Header
If Not rs.EOF Then
If strUnique <> rs("UniqueIdnt") Then
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="C"
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
strHdr = rs("UniqueIdnt") & "." & "TIME: " & rs("TrnTime") & "CASE
#" & rs("CaseNo")
strHdr = strHdr & vbCr & "CASE NAME: " & rs("TrnName") & vbCr
strHdr = strHdr & rs("TrnDesc1")
Selection.TypeText Text:=strHdr
Selection.SelectCell
Selection.Font.Name = "Arial"
Selection.Font.Bold = wdToggle
End If
End If
Wend
Selection.MoveLeft Unit:=wdCell
Selection.SelectColumn
Selection.Font.Name = "Arial"
Selection.Font.Size = 8
Selection.MoveLeft Unit:=wdCell
Selection.MoveLeft Unit:=wdCell
Selection.SelectColumn
Selection.Font.Name = "Arial"
Selection.Font.Size = 8
Selection.MoveLeft Unit:=wdCell
Selection.MoveLeft Unit:=wdCell
Selection.SelectColumn
Selection.Font.Name = "Arial"
Selection.Font.Size = 8
ActiveDocument.SaveAs FileName:=strSaveTo, FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False

ExitHere:
objWord.Documents.Close
objWord.Quit
Set objWord = Nothing
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Exit Sub

HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical,
cstrProcName
End Select
GoTo ExitHere

End Sub
 
D

Dirk Goldgar

SHIPP said:
I am getting the following error every 2nd time I run the code below.

Runtime Error 462

The remote server machine does not exist or is unavailable.

It is strange. I am not using a remote server. And it happens exactly
every
second time I run the code.

The error occurs at the line.

With ActiveDocument.PageSetup

Help, Please.


Public Sub sWordXport(strSaveTo As String)


'***************************************************************************************
'* PROGRAM : TRN
'* CREATED : 8/5/08
'* COMMENTS : Validates the current record
'* PARAMETERS: -
'* RETURNS : Boolean -
'* CALLED BY :
'* MODIFIED :

'***************************************************************************************

On Error GoTo HandleErr
Const cstrProcName As String = "modCDOEmail - sWordXport"

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim fld As Field
Dim strHdr As String
Dim strUnique As String

Dim objWord As Word.Application
Dim wDoc As Word.Document

' Set objWord = CreateObject("Word.Application")
' Set objWord = New Word.Application
' objWord.Documents.Add
' Set doc = objWord.ActiveDocument
' objWord.Visible = True

Set objWord = CreateObject("Word.Application")
' Set objWord = GetObject(, "Word.Application")
objWord.Documents.Add
' Set doc = objWord.ActiveDocument
objWord.Visible = True

Set db = CurrentDb()
Set rs = db.OpenRecordset("qryWordExport")

With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
' Create Header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.TypeText Text:="CONTRA COSTA SUPERIOR COURT"
Selection.TypeParagraph
Selection.TypeText Text:="MARTINEZ, CALIFORNIA"
Selection.TypeParagraph
Selection.TypeText Text:="DEPARTMENT: " & GetDept()
Selection.TypeParagraph
Selection.TypeText Text:="HEARING DATE: " & GetDateBeg()
Selection.WholeStory
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Font.Size = 14
Selection.Font.Name = "Arial"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument



' Create table
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=20, NumColumns
_
:=4, DefaultTableBehavior:=wdWord9TableBehavior ', AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = InchesToPoints(0.1)
Selection.SelectCell
Selection.TypeText Text:="H"
Selection.MoveRight Unit:=wdCell
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = InchesToPoints(0.1)
Selection.SelectCell
Selection.TypeText Text:="S"
Selection.MoveRight Unit:=wdCell
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = InchesToPoints(0.1)
Selection.SelectCell
Selection.TypeText Text:="T"
Selection.MoveRight Unit:=wdCell
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = InchesToPoints(6.7)
Selection.SelectCell
Selection.TypeText Text:="TENTATIVE RULING"

' Create the data
rs.MoveLast
rs.MoveFirst
' Create the first Header
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="C"
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
strHdr = rs("UniqueIdnt") & "." & "TIME: " & rs("TrnTime") & "CASE #" &
rs("CaseNo")
strHdr = strHdr & vbCr & "CASE NAME: " & rs("TrnName") & vbCr
strHdr = strHdr & rs("TrnDesc1")
Selection.TypeText Text:=strHdr
Selection.SelectCell
Selection.Font.Name = "Arial"
Selection.Font.Bold = wdToggle
While Not rs.EOF
strUnique = rs("UniqueIdnt")
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("TrnHdr")) Or Trim(rs("TrnHdr")) <> "" Then
Selection.TypeText Text:="H"
Else
Selection.TypeText Text:="D"
End If
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("sTrnID")) Then
Selection.TypeText Text:=rs("sTrnID")
End If
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("TrnID")) Then
Selection.TypeText Text:=rs("TrnID")
End If
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("TrnHdr")) Or Trim(rs("TrnHdr")) <> "" Then
Selection.TypeText Text:=rs("TrnHdr")
Selection.SelectCell
Selection.Font.Name = "Arial"
Selection.Font.Italic = wdToggle
Selection.Font.Bold = wdToggle
' If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
' Else
' Selection.Font.Underline = wdUnderlineNone
' End If
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 12
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
End If
Selection.MoveRight Unit:=wdCell
If Not IsNull(rs("TrnDtl")) Or Trim(rs("TrnDtl")) <> "" Then
Selection.TypeText Text:="D"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=rs("sTrnID")
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=rs("TrnID")
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=rs("TrnDtl")
Selection.SelectCell
Selection.Font.Name = "Arial"
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.2)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
Else
Selection.MoveLeft Unit:=wdCell
End If
rs.MoveNext
' Create the next Header
If Not rs.EOF Then
If strUnique <> rs("UniqueIdnt") Then
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="C"
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
strHdr = rs("UniqueIdnt") & "." & "TIME: " & rs("TrnTime") & "CASE
#" & rs("CaseNo")
strHdr = strHdr & vbCr & "CASE NAME: " & rs("TrnName") & vbCr
strHdr = strHdr & rs("TrnDesc1")
Selection.TypeText Text:=strHdr
Selection.SelectCell
Selection.Font.Name = "Arial"
Selection.Font.Bold = wdToggle
End If
End If
Wend
Selection.MoveLeft Unit:=wdCell
Selection.SelectColumn
Selection.Font.Name = "Arial"
Selection.Font.Size = 8
Selection.MoveLeft Unit:=wdCell
Selection.MoveLeft Unit:=wdCell
Selection.SelectColumn
Selection.Font.Name = "Arial"
Selection.Font.Size = 8
Selection.MoveLeft Unit:=wdCell
Selection.MoveLeft Unit:=wdCell
Selection.SelectColumn
Selection.Font.Name = "Arial"
Selection.Font.Size = 8
ActiveDocument.SaveAs FileName:=strSaveTo, FileFormat:=wdFormatDocument,
_
LockComments:=False, Password:="", AddToRecentFiles:=True,
WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False

ExitHere:
objWord.Documents.Close
objWord.Quit
Set objWord = Nothing
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Exit Sub

HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical,
cstrProcName
End Select
GoTo ExitHere

End Sub


I don't know if this is the source of the problem or not, but it seems to me
that most of those lines contain object references that should be qualified
with the Word application object you created:

With objWord.ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
' Create Header
objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With objWord.Selection
.TypeText Text:="CONTRA COSTA SUPERIOR COURT"
.TypeParagraph
.TypeText Text:="MARTINEZ, CALIFORNIA"
.TypeParagraph
.TypeText Text:="DEPARTMENT: " & GetDept()
.TypeParagraph
.TypeText Text:="HEARING DATE: " & GetDateBeg()
.WholeStory
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Size = 14
.Font.Name = "Arial"
End with
objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

'... and so on.
 
S

SHIPP

I did exactly what you said. Still, every other time, the code stops with the
error message 462. Please advise.
 
D

david

Add line numbers, so that you can see which line number causes
the problem, or remove
On Error GoTo HandleErr
so you can see which line causes the problem, or set the VBA option
Break On All Errors
so that you can see which line causes the problem.

Also, by the way, declare field as DAO.field: there are several
objects that have field properties.

(david)
 
D

Dirk Goldgar

SHIPP said:
I did exactly what you said. Still, every other time, the code stops with
the
error message 462. Please advise.


I'm not an expert in this area, but I have seen things like this caused by
improper reference handling, which is why I'm still suspicious of your Word
object references. You've got a lot of code there, so it would be easy to
overlook something. Please post your revised code, and I'll see if I can
spot something. It may take a while, so don't hold your breath in eager
anticipation.
 
B

BeWyched

Hi

I've had a similar problem when automating Outlook from Access. I have no
idea if my solution will solve your problem but it's worth a try...

Force late binding by changing the declaration for objWord to:
Dim objWord

Then change the late binding call to:
Set objWord = CreateObject("Word.Application", "localhost")

It's the localhost bit that solved it for me. The second, optional,
parameter shouldn't be needed as without it the local machine will be used.
But, for reasons I don't understand, on some PC's you need to force it to use
the local machine otherwise you get the 462 error.

Cheers.

BW
 

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