Remote server error

T

Thronz

My problem is that the coding (below) I have to print a document (from a
template) based on the current record (MSAccess Form) works fine for the
first instance, but after that I get an error message of "THE REMOTE SERVER
MACHINE DOES NOT EXIST OR IS UNAVAILABLE". If I restart the database the
document will print but I get the same error when I try to print any others.

The code is:

Private Sub Printform_Click()

Dim doc As String
Dim locat As String
Dim wrdApp As Word.Application
Dim fs As Object
Dim pDoc As Word.Document

Set fs = CreateObject("Scripting.FileSystemObject")
Set wrdApp = New Word.Application
Set pDoc =
wrdApp.Documents.Open(filename:="N:\Security\Reception\Forms\Contractor
Renewal Form.doc")
On Error GoTo Err_Printform_Click

locat = "N:\Security\Reception\Contractors" & "\" & Me.ID & ".jpg"
If fs.FileExists(locat) = False Then locat =
"N:\Security\Reception\Contractors\NoPix.JPG"

wrdApp.Visible = False
pDoc.FormFields("Name").Result = Lastname + ", " + Me.Given1 + " " &
Me.Given2
pDoc.FormFields("Address").Result = Me.Address & " " & Me.City
pDoc.FormFields("ID").Result = Me.ID
pDoc.FormFields("DOB").Result = Me.DOB
pDoc.FormFields("Employer").Result = Me.Employer
pDoc.FormFields("Reason").Result = Me.ReasonforAccess
pDoc.FormFields("Contact").Result = Contact
pDoc.Bookmarks("Photo").Select
Selection.InlineShapes.AddPicture filename:=locat
Options.PrintBackground = False

pDoc.PrintOut
pDoc.ResetFormFields
wrdApp.Documents.Close saveChanges:=wdDoNotSaveChanges
wrdApp.NormalTemplate.Saved = True
wrdApp.Quit
Set wrdApp = Nothing
Set pDoc = Nothing

GoTo 100

Err_Printform_Click:

MsgBox (Error)
pDoc.ResetFormFields
wrdApp.Documents.Close saveChanges:=wdDoNotSaveChanges
wrdApp.NormalTemplate.Saved = True
wrdApp.Quit
Set wrdApp = Nothing
Set pDoc = Nothing
100
End Sub
 

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

Similar Threads

open word document 0
Problem with Normal.dot 2
data to documents 1
Error 2147418113 -Method failed 2
automation and security 1
Word 2003/2007 Prompting To Save Document 5
ERROR 462 2
security and automation 0

Top