N
Ngan Bui
I have office XP and used the code from the KB article to
sent the current Access XP record to Word using
Automation: http://support.microsoft.com/default.aspx?
scid=KB;EN-US;q210271&
Once in awhile, one user gets the error 462 remote server
does not exist or is unavailable. In my code, I do not
quit Word because the user needs to preview and print the
doc. She then closes the Word and not save the file. At
this point is when the error happens. This problem is not
happening on any other computer.
I've done a search thru google about this error and read
about issues one may run into using early binding and
about Automation Error Calling Unqualified Method or
Property (http://support.microsoft.com/default.aspx?
scid=kb;EN-US;189618).
I'm not quite sure where to fix the problem in my code,
and why only one user is having this problem. Please
help! Below is a snippet of the code:
Private Sub prevletter_Click()
On Error GoTo err_prevletter
Dim filepath, strDocName As String
Dim objWord As Word.Application
Dim wdDoc As Word.Document
filepath = "O:\Databases\Documents\Complaints\"
strDocName = "CompResponse" & F!LetterVersion & ".dot"
' Start Microsoft Word.
Set objWord = CreateObject("Word.Application")
Set wdDoc = objWord.Documents.Add(filepath & strDocName)
With objWord
' Make the application visible.
.Visible = True
' Move to each bookmark and insert text from the
form.
.ActiveDocument.Bookmarks("SentDate").Select
.Selection.Text = (Format(F!SentDate, "mmmm d,
yyyy"))
.ActiveDocument.Bookmarks("FirstName").Select
.Selection.Text = (CStr(F2!FirstName))
.ActiveDocument.Bookmarks("LastName").Select
.Selection.Text = (CStr(F2!LastName))
....
End With
Set wdDoc = Nothing
Set objWord = Nothing
Exit Sub
exit_prevLetter:
objWord.Quit
Set wdDoc = Nothing
Set objWord = Nothing
Exit Sub
err_prevletter:
' If a field on the form is empty
' remove the bookmark text and continue.
If Err.Number = 94 Then
objWord.Selection.Text = ""
Resume Next
Else
MsgBox Err.Number & vbCr & Err.Description
End If
Resume exit_prevLetter
End Sub
sent the current Access XP record to Word using
Automation: http://support.microsoft.com/default.aspx?
scid=KB;EN-US;q210271&
Once in awhile, one user gets the error 462 remote server
does not exist or is unavailable. In my code, I do not
quit Word because the user needs to preview and print the
doc. She then closes the Word and not save the file. At
this point is when the error happens. This problem is not
happening on any other computer.
I've done a search thru google about this error and read
about issues one may run into using early binding and
about Automation Error Calling Unqualified Method or
Property (http://support.microsoft.com/default.aspx?
scid=kb;EN-US;189618).
I'm not quite sure where to fix the problem in my code,
and why only one user is having this problem. Please
help! Below is a snippet of the code:
Private Sub prevletter_Click()
On Error GoTo err_prevletter
Dim filepath, strDocName As String
Dim objWord As Word.Application
Dim wdDoc As Word.Document
filepath = "O:\Databases\Documents\Complaints\"
strDocName = "CompResponse" & F!LetterVersion & ".dot"
' Start Microsoft Word.
Set objWord = CreateObject("Word.Application")
Set wdDoc = objWord.Documents.Add(filepath & strDocName)
With objWord
' Make the application visible.
.Visible = True
' Move to each bookmark and insert text from the
form.
.ActiveDocument.Bookmarks("SentDate").Select
.Selection.Text = (Format(F!SentDate, "mmmm d,
yyyy"))
.ActiveDocument.Bookmarks("FirstName").Select
.Selection.Text = (CStr(F2!FirstName))
.ActiveDocument.Bookmarks("LastName").Select
.Selection.Text = (CStr(F2!LastName))
....
End With
Set wdDoc = Nothing
Set objWord = Nothing
Exit Sub
exit_prevLetter:
objWord.Quit
Set wdDoc = Nothing
Set objWord = Nothing
Exit Sub
err_prevletter:
' If a field on the form is empty
' remove the bookmark text and continue.
If Err.Number = 94 Then
objWord.Selection.Text = ""
Resume Next
Else
MsgBox Err.Number & vbCr & Err.Description
End If
Resume exit_prevLetter
End Sub