Hi,
I,m trying to embed pdf-files to several notesdocument with an lotus script agent. But I get the “object variable not set” all the time. If I open the document and write something to the rich text field, save it and then remove the text and saving it again ,then my agent works fine. But if the document is “untouched” it won´t work. My agent is trigged by a button in a view. What have I missed,missunderstod? Here is my code:
Dim rtitem As NotesRichTextItem
Dim object As NotesEmbeddedObject
Dim path As String
Dim code As String
Dim fileend As String
Dim municipality As String
Set sess=New NotesSession
Set db=sess.CurrentDatabase
Set view=db.Getview(“vimport”)
path=Inputbox ( “Find the path?” , “Stat” , "h:\files" )
fileend=“.pdf”
Set doc=view.GetFirstDocument
While Not (doc Is Nothing)
Set rtitem=doc.GetFirstItem(“file”)
code=doc.mcode(0)
If Not doc.HasItem(“$File”) Then
Set object = rtitem.EmbedObject_
( EMBED_ATTACHMENT,“”, path+code+fileend)
Call doc.Save(True, False)
Else
Set object = rtitem.GetEmbeddedObject(code+fileend)
Call object.Remove
Set object = rtitem.EmbedObject _
( EMBED_ATTACHMENT,“”, path+code+fileend)
Call doc.Save(True, False)
End If
Set doc=view.GetNextDocument(doc)
Wend
thankfull for any help.
Carola