akn112
10-09-2007, 11:48 AM
I've tried asking/searching everywhere but can't seem to get it figured out:banghead:
I'm getting a runtime error sometimes when i try to run the below sub. But it fails at the openworkbooks method sometimes. the error is :
"Remote Server Machine Does not Exist or is Unavailable"
I've also triple checked the file name and everything but still doesnt budge. I've been trying to debug this problem the whole day...and it's killing my brain cells :bug: Heres the code:
Sub Letter_(strTemplateFilePath As String, userCompleteFilePath As String, wordApplication As Word.Application, uaUserAccess As CUserAccess)
Dim wordDocument As Word.Document, wordDocumentAppendixA As Word.Document
Dim docDocument As Document
Dim combineFileName As String
Dim sections As String
Dim eaExcelApplication As Excel.Application
combineFileName = buildFileName(uaUserAccess, "COMBINE")
'Get the excel app
'Check for existing instance of Excel
On Error Resume Next
Set eaExcelApplication = GetObject(, "Excel.Application")
On Error GoTo 0
If eaExcelApplication Is Nothing Then
Set eaExcelApplication = CreateObject("Excel.Application")
End If
eaExcelApplication.WorkBook.Open CurrentProject.Path & IdentityMgmtFolder & "Archive\Combined\" & combineFileName, , , , "xxPass"
' On Error Resume Next
For Each docDocument In wordApplication.Documents
If docDocument.Path & "\" & docDocument.Name = userCompleteFilePath Then
wordApplication.Documents(docDocument.Name).Close SaveChanges:=True
End If
Next
'On Error Resume Next
Call FSOCopy(strTemplateFilePath, userCompleteFilePath)
Set wordDocument = wordApplication.Documents.Open(userCompleteFilePath)
With wordApplication
...
I'm getting a runtime error sometimes when i try to run the below sub. But it fails at the openworkbooks method sometimes. the error is :
"Remote Server Machine Does not Exist or is Unavailable"
I've also triple checked the file name and everything but still doesnt budge. I've been trying to debug this problem the whole day...and it's killing my brain cells :bug: Heres the code:
Sub Letter_(strTemplateFilePath As String, userCompleteFilePath As String, wordApplication As Word.Application, uaUserAccess As CUserAccess)
Dim wordDocument As Word.Document, wordDocumentAppendixA As Word.Document
Dim docDocument As Document
Dim combineFileName As String
Dim sections As String
Dim eaExcelApplication As Excel.Application
combineFileName = buildFileName(uaUserAccess, "COMBINE")
'Get the excel app
'Check for existing instance of Excel
On Error Resume Next
Set eaExcelApplication = GetObject(, "Excel.Application")
On Error GoTo 0
If eaExcelApplication Is Nothing Then
Set eaExcelApplication = CreateObject("Excel.Application")
End If
eaExcelApplication.WorkBook.Open CurrentProject.Path & IdentityMgmtFolder & "Archive\Combined\" & combineFileName, , , , "xxPass"
' On Error Resume Next
For Each docDocument In wordApplication.Documents
If docDocument.Path & "\" & docDocument.Name = userCompleteFilePath Then
wordApplication.Documents(docDocument.Name).Close SaveChanges:=True
End If
Next
'On Error Resume Next
Call FSOCopy(strTemplateFilePath, userCompleteFilePath)
Set wordDocument = wordApplication.Documents.Open(userCompleteFilePath)
With wordApplication
...