Das Notes Forum

Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: olli am 02.07.02 - 13:29:57

Titel: Dokument mit Anhang erstellen und öffnen
Beitrag von: olli am 02.07.02 - 13:29:57
Moin!

Ziel ist es ein Dokument mit Anhang über eine Aktion zu erstellen. Das Dokument soll sich öffnen und der Anhang dann automatisch gestartet werden. Mein Code sieht zur Zeit folgendermaßen aus:
Sub Click(Source As Button)
     Dim Session As New NotesSession
     Dim db As NotesDatabase
     Dim note As NotesDocument
     Dim item As NotesRichTextItem
     Dim obj As NotesEmbeddedObject
     
     Set db = session.currentDatabase
     Set note = Db.CreateDocument
     Set item = New NotesRichTextItem(note, "Body")
     Set obj = item.EmbedObject(EMBED_ATTACHMENT,"","C:\TEMP\letter.doc","Worddokument")
     Call note.Save(True, False)
           
     
End Sub

Dieser Code erzeugt ein Dokument. Wie muß ich den Code erweitern, daß dieses Dokument geöffnet und der Anhang gestartet wird?

Mit Bitte um HILFE

olli
PS: Ich entwickle lokal auf Release 5.0.9
Titel: Re: Dokument mit Anhang erstellen und öffnen
Beitrag von: doliman am 02.07.02 - 19:19:46
Hi,
versuchs mal damit Ich habe es etwas verkürzt und es wird eine Vorlage aus einem anderen Notesdokument benutzt, das must Du ggf. entfernen:

Sub Postopen(Source As Notesuidocument)
     
     Dim session As New NotesSession      
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Dim view As NotesView
     Dim object As NotesEmbeddedObject
     Dim handle As Variant
     Dim WordObj As Variant
     
     Dim rtitem As NotesRichTextItem
     'Check if new document, if yes create new word doc, if not open from document
     If Source.IsNewDoc Then
           'Copy Letter from template to c:\temp\temp.doc and then attach to new document
           Set db = session.CurrentDatabase
           Set view =  db.getView("Standard Templates")
           Set doc = view.GetDocumentByKey("Standard Letter",True)
           Set object = doc.GetAttachment( "letter.doc" )
           Call object.ExtractFile( "c:\temp\temp.doc" )
           Call Source.GotoField( "Body" )
           
           Call Source.CreateObject("Letter","","c:\temp\temp.doc")
           Set WordObj = Source.GetObject( "Letter" )      
           
           
           'Aktiviert Word als aktive Anwendung
           WordObj.activate
           WordObj.Fields.Update
           WordObj.Application.Visible=True
           WordObj.Application.WindowState = 1
           WordObj.Windows.Add
           WordObj.Application.Activate
     Elseif Source.Inpreviewpane = False Then
         'Get object and activate Word            
           Set WordObj = Source.GetObject( "Letter" )      
           WordObj.activate
           WordObj.Application.Visible=True
           WordObj.Application.WindowState = 1
           WordObj.Windows.Add
           WordObj.Application.Activate
     End If
End Sub