Run-time error '462' remote server machine does not exist

i'm trying to send data from ms access 2007 to word 2007 into a template with bookmarks, the information is based on the open form where it queries for the other data for the word document. but for now i'm testing it to be able to send an resend it without having to close the application or to end the debug window when the error occurs.
I need help figuring out what is not working in my code. when i first run it, it works fine. i close the word application and when i try it again it gives me the [b]Run-time error '462' the remote server machine does not exist or is unavailable[/b]

here is the code

[color=Green]Private Sub Command66_Click()

Dim objWord As Word.Application
Dim cst As dao.Recordset
Dim dbs As Object
Dim qdf As New QueryDef
Dim chdf As New QueryDef
Set objWord = New Word.Application

With objWord

' Make the application visible.
objWord.Visible = True
' Open the document.
objWord.Documents.Open ("c: est.doc")

Set dbs = CurrentDb()
Set chdf = dbs.QueryDefs("FrmLinkDocQuery")
chdf.Parameters("[Forms]![pmir]![pmirid]") = [Forms]![pmir]![PMIRID]
Set cst = chdf.OpenRecordset()

'go to first bookmark in word document
objWord.Selection.GoTo What:=wdGoToBookmark, Name:="TimeStamp"

'insert data into word document
With cst
Do While Not .EOF
'Insert data into labels
Selection.TypeText Text:=![Timestamp]
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=![Description]
Selection.MoveRight Unit:=wdCell
End With

End With

Set objWord = Nothing

Set cst = Nothing

Set dbs = Nothing

Set qdf = Nothing

Set chdf = Nothing

End Sub[/color]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion