I have run into a strange problem that seems to only occur for some people a handful of times and haven’t been able to pinpoint the cause. We have an agent that when triggered by a form action it creates a Word document, saves it to c:\temp, and then attaches that newly created Word document to a rich text field (called Attachment). Suddenly, I have 3 users that get an error message that says ‘Invalid or Non-Existent document’ when this code is running. It appears as if the file is not being recognized. When debugging the code, the line that it errors out on is ‘Set object=rtitem.EmbedObject(EMBED_ATTACHMENT,“”, currentFileName & “.dot”)’. If I reference an Err number, I get error 4067. I am unable to reproduce the problem on my pc which has the exact same version of Notes and Windows.
Can anyone tell me why this would only happen to a few people and how I can fix it? Any help would be greatly appreciated!
Sub Initialize
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
'Template Processing
If Template_Process() = False Then
Exit Sub
End If
'Create the Word object:
Set WordApp = CreateObject("Word.Application")
WordApp.documents.open(filename)
Set doc = dc.GetFirstDocument()
If doc Is Nothing Then Exit Sub
Call GetFieldList
If dc.Count = 1 Then
'Populate the Word Template
For i = 0 To Ubound(fieldList)
WordApp.ActiveDocument.Bookmarks(fieldName(i)).Select
WordApp.Selection.TypeText(fieldList(i))
Next
poNum = doc.PONum(0)
poNum = Left(poNum, 4) & Mid(poNum,6)
currentFileName = tmpdir & "\" & poNum
WordApp.ActiveDocument.saveas (currentFileName)
WordApp.ActiveDocument.close
WordApp.Quit
'Add attachment to document
Dim rtitem As notesrichtextitem
Dim object As notesEmbeddedObject
Set rtitem=New NotesRichTextItem (doc,"Attachment")
Set object=rtitem.EmbedObject(EMBED_ATTACHMENT,"", currentFileName & ".dot")
'Set DocAuthors field
Dim author(2) As String
author(0) = "[Designer]"
author(1) = "[Maintenance]"
author(2) = "[Receiver]"
doc.DocAuthors = author
Call doc.Save(True, False)
End If
If doc.EmailPO(0) = "Yes" Then
Call SendEmail
End If
End Sub