Hi
I am trying to use the following code to open a Word template, insert text based on the field [Job] and then save the document to folder as per the field [docfolder].
The code works perfectly but only on every 2nd attempt. When it doesn't work I get the following error:
Run time error '462"
The remote server machine does not exist or is unavailable.
The error concerns the line Word.Application.ActiveDocument.SaveAs (MSQname)
Any advice would be greatly appreciated.
Thanks
AL
I am trying to use the following code to open a Word template, insert text based on the field [Job] and then save the document to folder as per the field [docfolder].
Code:
Sub msq()
Dim MSQname As String
MSQname = Forms![frm recs tracked jobs]![docfolder] & "\" & Forms![frm recs tracked jobs]![Job] & " MSQ.doc"
Set objword = New Word.Application
With objword
.Visible = True
.Documents.Add Template:=("i:\ia manual\management satisfaction questionnaire.dot")
.Selection.GoTo Name:=("JobName")
.Selection.TypeText Text:=(Forms![frm recs tracked jobs]![Job])
End With
Word.Application.ActiveDocument.SaveAs (MSQname)
Word.Application.Quit
End Sub
The code works perfectly but only on every 2nd attempt. When it doesn't work I get the following error:
Run time error '462"
The remote server machine does not exist or is unavailable.
The error concerns the line Word.Application.ActiveDocument.SaveAs (MSQname)
Any advice would be greatly appreciated.
Thanks
AL