View Single Post
 
Old 01-21-2013, 06:33 AM
silverspr silverspr is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Apr 2011
Posts: 24
silverspr is on a distinguished road
Default Error 462 remote server does not exist or is not available

HI I wonder if you could help one more time. The script you assisted with earlier, is being called from within Access. I can only run the routine that calls this script once. Then I get the 462 error. My research tells me word is not being closed properly however when opening task manager I can't see any word instances running. Below is the calling script with the line closing word in red:

Function OpenWd()
Dim appWord As Word.Application, strdir As String, strfile As String, strarchive As String
Dim doc As Word.Document
Dim MyDB As Database
Dim rst As Recordset
Dim strDocName As String
Dim blnQuitWord As Boolean

strTemp1 = DLookup("[sFilePath]", "tblconfig", "[description] like ""filepath temp1""")
strdir = DLookup("[sFilePath]", "tblconfig", "[description] like ""filepath strdir""")
strarchive = DLookup("[sFilePath]", "tblconfig", "[description] like ""filepath archive""")

Kill strTemp1
Open strTemp1 For Append As #1

Print #1, """" & "QID" & """" & Chr(59) & """" & "Response" & """" & Chr(59) & """" & "Reviewee" & """"
Close #1
On Error GoTo ErrorHandling

strfile = dir(strdir)

Do While strfile <> ""
strDocName = strdir + strfile

Set appWord = GetObject(, "Word.Application")
Set doc = appWord.Documents.Open(strDocName)
appWord.Visible = False
'With doc
Debug.Print strDocName
Call RenameWdFormFields 'heres where I call the script you helped with
Call GetFld(strTemp1)
'End With

appWord.Documents.Close savechanges:=wdDoNotSaveChanges
strfile = dir()

Loop

If blnQuitWord Then appWord.Quit
'MsgBox "complete"

Cleanup:
'doc.Close
Set rst = Nothing
Set doc = Nothing
Set appWord = Nothing
Exit Function

ErrorHandling:
Select Case Err
Case -2147022986, 429
Set appWord = CreateObject("Word.Application")
blnQuitWord = True
Resume Next
Case 5121, 5174
MsgBox "You must select a valid Word document. " _
& "No data imported.", vbOKOnly, _
"Document Not Found"
Case 5941
MsgBox "The document you selected does not " _
& "contain the required form fields. " _
& "No data imported.", vbOKOnly, _
"Fields Not Found"
Case Else
MsgBox Err & ": " & Err.Description
End Select
GoTo Cleanup
Reply With Quote