Good Day All,
I am stumped. I have code that is called from a button click in document A, it finds and extracts the attachments from document B, then it is supposed to come back to document A and embedded all the attachments from the specific folder.
So far I am getting the attachments to detach from B. I can see them in the correct folder. I can see that B closes and I am back at A. However when it gets near my line of code I keep getting an Object Variable Not Set error at the If (rtitem2.Type = RICHTEXT) Then line. I am not seeing what it is that I haven’t set/declared so would appreciate an extra set of eyes. Along with the error, the attachments are not getting embedded in the Attach1 field.
Sub Initialize
Dim workspace As New notesuiworkspace
Dim session As New NotesSession
Dim CC_db As NotesDatabase
Dim CurDoc As NotesDocument
Dim uidoc As NotesUIDocument, uidocNew As NotesUIDocument
Dim doc As NotesDocument
Dim w As NotesUIWorkspace
Dim view As NotesView
Dim key As Variant
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Call doc.Save(True, True)
key = "7C480947F9DA63F48825753D005A55E9"
Set CC_db = session.CurrentDatabase
Set view = CC_db.GetView( "(Links)" )
Set CurDoc = view.GetDocumentByKey(key , True )
If CurDoc Is Nothing Then
Messagebox "No such document database.",,"document not Found"
Exit Sub
Else
Call workspace.EditDocument(False, CurDoc)
Set sess = New NotesSession
Set db = sess.CurrentDatabase
Set uidocNew = workspace.CurrentDocument
Dim rtitem As Variant
Dim object As NotesEmbeddedObject
Set rtitem = Curdoc.GetFirstItem( "Link" )
Dim eOArray As Variant
eOArray = rtitem.EmbeddedObjects
If Isempty(eOArray)Then
Else
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
fn = o.source
nam = fn '**
Do While fileName$ <> ""
fileName$ = Dir$()
count = count +1
Loop
splitName = Split(nam,".",2)
nam = splitName(0) &"_" & count & "." & splitName(1)
Call o.ExtractFile( "C:\temp\"& nam )
Else
End If
End Forall
End If
Dim uidoc1 As NotesUIDocument
Set uidoc1 = workspace.CurrentDocument
Call uidoc1.Close
Dim rtitem2 As Variant
Dim object2 As NotesEmbeddedObject
Dim uidoc2 As NotesUIDocument
Dim doc2 As NotesDocument
Set uidoc2 = workspace.CurrentDocument
Set doc2 = uidoc2.Document
'*******************************************************************
Set rtitem2 = doc2.GetFirstItem( "Attach1" )
If ( rtitem2.Type = RICHTEXT ) Then ' OBJECT VARIABLE NOT SET
Set object2 = rtitem2.EmbedObject( EMBED_ATTACHMENT, "", "C:\temp\" & nam )
End If
'*******************************************************************
End If
End If
End Sub
Thanks in advance for any help.
Teri