Domino 9 und frühere Versionen > ND6: Entwicklung

Images in Richtextfelder attachen

(1/3) > >>

Stephanie:
Hallo Zusammen

Ich habe folgendes Problem. Würde gerne Bilder aus einem vordefinierten Pfad in diverse Notes Richtextfelder attachen.

Die Bilder werden wohl ins Dokument geschrieben jedoch nur in $FILE Felder. Kann man das umgehen.

Dim ses As New NotesSession
Dim uiw As New NotesUIWorkspace
Dim uid As NotesUIDocument
Dim ndb As NotesDatabase
Dim docCurrent As NotesDocument
Dim fileNameBig As String
Dim fileNameSmall As String
Dim rtitemBig As NotesRichTextItem
Dim rtitemSmall As NotesRichTextItem
Dim pathNameBig As String
Dim pathNameSmall As String
Dim pathNameBigEmb As String
Dim pathNameSmallEmb As String
Dim i As Integer
Dim FileNumber As String
Dim FileNumberSmall As String

Set uid = uiw.CurrentDocument
Set docCurrent = uid.Document

pathNameBig$ = "c:\Restwertzentrale\original\*.*"
pathNameBigEmb$ = "c:\Restwertzentrale\original\"
pathNameSmall$ = "c:\Restwertzentrale\thumbs\*.*"
pathNameSmallEmb$ = "c:\Restwertzentrale\thumbs\"
fileNameBig$ = Dir$(pathNameBig$, 0)

i = 0
Do While fileNameBig$ <> ""
i = i + 1
      
If i <= 15 Then
Set rtitemBig = docCurrent.GetFirstItem( "ImageB" & i )
If ( rtitemBig.Type = RICHTEXT ) Then
FileNumber$ = NotesLeft(fileNameBig$, "-", False)
Call rtitemBig.EmbedObject( EMBED_ATTACHMENT, "", pathNameBigEmb$ & fileNameBig$)
Kill pathNameBigEmb$ & fileNameBig$

fileNameSmall$ = Dir$(pathNameSmall$, 0)
Do While fileNameSmall$ <> ""
FileNumberSmall$ = NotesRight(NotesLeft(fileNameSmall$, "-", False), "_", True)
If FileNumber$ = FileNumberSmall$ Then

Set rtitemSmall = docCurrent.GetFirstItem( "ImageS" & i )
If ( rtitemSmall.Type = RICHTEXT ) Then
Call rtitemSmall.EmbedObject( EMBED_ATTACHMENT, "", pathNameSmallEmb$ & fileNameSmall$)
Kill pathNameSmallEmb$ & fileNameSmall$
Exit Do
End If
End If
fileNameSmall$ = Dir$()   
Loop
            
End If
End If
fileNameBig$ = Dir$(pathNameBig$, 0)
Loop
   
Call docCurrent.Save(True, True)

Bin für jede Hilfe dankbar.

Gruss

Stéphanie

TMC:
Stephanie,
bitte beantworte auch Deine offenen Beiträge:
http://www.atnotes.de/index.php?topic=18857.0

Zu diesem Beitrag hier:
Meinst Du damit, dass die Attachments nicht sichtbar sind, wenn Du das Dokument öffnest?
$Files sind prinzipiell entwicklerseitig ziemlich uninteressant. Interessant ist, was das RT-Item beinhaltet. Dazu solltest Du noch ein paar Infos geben, also was genau in Deinem RT-Item enthalten ist nach dieser Aktion.

TMC:
Noch was:

Designerhilfe sagt zu embedded Object:

--- Zitat ---For this method to work you must set a default view in the database.
--- Ende Zitat ---

Probiere auch mal einen BackendDoc.Save nach jedem attachen, nicht erst zum Schluss.

Stephanie:
Hallo Matthias

Also meine RT-Item sind leer nach dem ich das Script laufengelassen habe, jedoch werden diverse $FILE Felder erstellt. Eine Default view habe ich auch und einen BackendDoc.Save nach jedem attachen funktioniert leider auch nicht.

Stéphanie

TMC:
Stephanie,

hast Du den Code mal durch den Debugger laufen lassen und dort alle Variablen geprüft?

Was sein könnte auf den 1. Blick:

--- Code: ---Set rtitemBig = docCurrent.GetFirstItem( "ImageB" & i )
--- Ende Code ---

Das gefällt mir irgendwie nicht. Ich weiß jetzt nicht, ob hier automatisch als String ein "ImageB13" erstellt wird, wenn das Integer = 13 ist. Z.B. in einer Msgbox wird das umgewandelt. Mach mal testweise ein CStr(i) statt i.
Gibt es denn die RT-Felder "ImageB1", ImageB2 etc. in dem Dokument?

Bei mir funktioniert z.B. dieser Code hier astrein (gestartet von einem Button aus einem geöffnetem Dokument), es erscheint ein Attachment im Richtextfeld "Body":


--- Code: --- Dim uiws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim vFile As Variant
Dim rti As NotesRichTextItem
Set db = session.CurrentDatabase
Set uidoc = uiws.CurrentDocument
Set doc = uidoc.Document
vFile = uiws.OpenFileDialog( False, db.Title, "All files|*.*|", "c:\")
If Isempty(vFile) Then Exit Sub
Set rti = doc.GetFirstItem("Body")
Call rti.EmbedObject( EMBED_ATTACHMENT, "", vFile(0))
Call doc.Save( True, True )
--- Ende Code ---

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln