JPG Files per Agent inn ein Dokument

  • Hallo,


    hat jemand von euch schonmal einen Agenten geschrieben der per Script JPG Files in ein Dokument speichert ( Richtext Feld). Und danach sollen beim öffnen des jeweiligen Dokumentes die Bilder sichtbar sein.
    Wäre dankbar wenn man mir wenigstens ein Beispiel geben kann wie ich das am besten lösen kann.
    Danke im voraus.

  • hi,


    schau dir mal die klasse "notesrichtextitem" an. diese enthält die methode "Embedobject".


    notes kennt (zum. in version 5) 3 arten von embededobjects:


    -EMBED_ATTACHMENT
    -EMBED_OBJECT
    -EMBED_OBJECTLINK


    Der Typ den du anlegen willst müsste vom Typ "EMBED_OBJECT" sein.


    der befehl zum anhängen müsste dann in etwa so lauten:


    call notesRichTextItem.EmbedObject( EMBED_OBJECT, "", "pfad auf die bilddatei")

  • Hi,


    habes es mit dem Befehl
    call notesRichTextItem.EmbedObject( EMBED_OBJECT, "", "pfad auf die bilddatei")
    probiert aber es funzt nicht benötige bitte dazu noch mehr info.

  • Welche fehlermeldung bekommst du ?
    Lass dich mittels msgbox den pfad mal als text darstellen, vielleicht hast du da einfach einen fehler drin, "c:\\temp\\datei.jpg" sollte es mindestens sein (sprich doppelten \)

  • Hallo ich weiß das einige es nicht mögen das man hier Scripts ablegt aber ich mache es zum besseren Verständnis.


    Also das folgende Script zum Import vom JPG Files
    Bei "Set object = rtitem.EmbedObject(EMBED_ATTACHMENT, "", filename) bekomme ich die Fehlermeldung Object variable not set


    On Error Goto ErrHandler
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim doc As NotesDocument
    Dim rtitem As NotesRichTextItem
    Dim object As NotesEmbeddedObject
    Dim filename As String
    Dim ImageType As String
    Dim ImageHeight As String
    Dim ImageWidth As String
    Dim ImageDepth As String

    ' Open a dialogbox and allow users to select from a list of files
    ' NB: PNG is missing from here as Notes can't import PNG image types.
    files = workspace.OpenFileDialog(True, "File List", "Supported Images|*.jpg;*.bmp;*.gif", "C:\")
    If Isempty(files) Then Exit Sub ' Exit if the user selects the Cancel button
    Forall FileList In files ' Loop through the list of files selected
    Filename = Filelist ' Get the current filename

    ' GetImageProperties returns an array of ImageType, height, width and bit-depth

    imgProps = GetImageProperties(Filename)
    ImageType = imgProps(0) ' Get the image type, BMP-GIF-JPEG-PNG
    ImageHeight = imgProps(1) ' Get the image height
    ImageWidth = imgProps(2) ' Get the image width
    ImageDepth = imgProps(3) ' Get the image bit-depth

    ' Now, we will create a new document and attach the selected image to it.
    Set db = session.CurrentDatabase ' Get the current database
    Set coll=db.unprocesseddocuments
    Set doc=coll.getfirstdocument
    'Set rtitem = doc.GetFirstItem( "Bild" )
    '######
    'filename = "c:\\65003.jpg"
    '
    Set rtitem = doc.GetFirstItem("Bild")
    Set object = rtitem.EmbedObject ( EMBED_ATTACHMENT, "", filename) ' Attach the file to it
    'Set rtitem = New NotesRichTextItem( doc, "Bild" ) ' Create a new richtext item
    Set object = rtitem.EmbedObject ( EMBED_ATTACHMENT, "", filename) ' Attach the file to it
    doc.Form = "Document" ' Set the form name
    'doc.HEIGHT = Cint(ImageHeight) ' Write the height
    'doc.Width = Cint(ImageWidth) ' Write the width
    'doc.colordepth = Cint(ImageDepth) ' Write the colour depth
    'doc.filesize = Filelen(filename) ' Write the filename
    Call doc.Save( True, True ) ' Save the backend document
    ' Once we have attached the image, we can open the document in the front-end and
    ' import the same file so we have a preview version.
    Set uidoc = workspace.EditDocument( True, doc ) ' Open the backend doc in the UI
    'Call uidoc.GotoField( "Bild" ) ' Make the ImageView field the focus

    Select Case Imagetype ' Select which image type this file is
    Case "GIF":
    Call uidoc.Import("GIF Image",filename) ' Import the GIF image into the field
    Call uidoc.fieldsettext("ImageType", "GIF Image") ' Set the Image type field
    Case "JPEG":
    Call uidoc.Import("JPEG Image",filename) ' Import the JPEG image into the field
    'Call uidoc.fieldsettext("ImageType", "JPEG Image") ' Set the Image type field
    Case "PNG":
    ' NB: This will never happen as Notes doesn't import PNG files although it's there if we need it
    Call uidoc.Import("PNG Image",filename) ' Import the PNG image into the field
    Call uidoc.fieldsettext("ImageType", "PNG Image") ' Set the Image type field
    Case "BMP":
    Call uidoc.Import("BMP Image",filename) ' Import the BMP image into the field
    Call uidoc.fieldsettext("ImageType", "BMP Image") ' Set the Image type field
    End Select

    Call uidoc.FieldSetText("Filename", filename) ' Set the filename field

    uidoc.CollapseAllSections ' Collapse the preview section
    uidoc.save ' Save the UI Doc
    uidoc.close ' Close the UI Doc
    End Forall ' loop through any of the remaining files

    '############################################################################################

    errPos = 10

    ExitSub:

    Exit Sub

    ErrHandler:
    Print ">> Fehler in dem Bildimport: " & Error & " in Zeile " & Erl & " !!!"
    Select Case errPos
    Case 10: Resume ExitSub
    'Case 20: Resume LBLPOS30
    'Case 30: Resume LBLPOS40

    'Case 70: Resume LBLPOS80
    Case default: Resume ExitSub
    End Select
    Resume exitsub





    Bei "Set object = rtitem.EmbedObject(EMBED_ATTACHMENT, "", filename) bekomme ich die Fehlermeldung Object variable not set

  • hi,


    das steht in der hilfe des designers zur "GetFirstItem"-Methode des NotesDocument-Objects:


    ----------------------
    The solution to this problem is to declare a variant, set it equal to the return value of GetFirstItem, and then treat the variant as a NotesRichTextItem. For example:
    Dim doc As NotesDocument
    Dim rtitem As Variant
    '...set value of doc...
    Set rtitem = doc.GetFirstItem( "Body" )
    If ( rtitem.Type = RICHTEXT ) Then
    '...use NotesRichTextItem methods...
    End If
    ----------------------


    mit anderen worten: wenn du die "getfirstitem"-value methode nutzt musst du deine "richtextitem"-variable als variant deklarieren...

  • Hi,


    der Agent steigt immer noch beim Embedd Attachemnent aus.
    Habe mal folgendes auspropiert:
    Im Dokumnet wo das Bild importiert werden soll habe ich eine Schaltfläche eingebaut mit folgender Formel was auch funktioniert


    BildPfad :="c:\\bilder\\";
    BildArtikel :=Artikelnummer+".jpg";
    @Command([EditDocument]);
    @Command([EditGotoField];"Bild");
    @Command([FileImport]; "JPEG Image";BildPfad +BildArtikel);
    @Command([FileSave]);
    @Command([FileCloseWindow])


    Nun zu meiner Frage kann ich per Agent für ausgewählte Dokumente diese Formel ansprechen wenn Ja sagt mir bitte wie