Domino 9 und frühere Versionen > ND8: Entwicklung
Bild per Script nach Word exportieren - Fehler: Grafikfilter konnte File nicht..
(1/1)
tburnens:
Hallo liebe Notes-Gemeinde!
nachdem Ihr mir schon zahlreiche Male ohne mein Zutun geholfen habt, darf ich Euch nun direkt befragen. (Ich entschuldige mich für allfällige formale Fehler meines Beitrags.)
Ich versuche mit LotusScript eine Microsoft Word 2010 Vorlage (.dotx) mit Werten aus einer Lotus Notes DB zu füllen. Dies klappt soweit problemlos. Wenn ich aber ein Bild einzufügen versuche, erhalte ich von Lotus Notes die folgende Fehlermeldung: "Microsoft Word: Der Grafikfilter konnte diese Datei nicht konvertieren." Im Header steht: "IBM Lotus Notes".
hier der Code der den Fehler verursacht:
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim currdb As NotesDatabase
Dim item As NotesItem
Dim WrdTempNotesdoc As NotesDocument
Set db = session.CurrentDatabase
Dim SurveyType As String
Dim rtitem As NotesRichTextItem
Dim wordobject As NotesEmbeddedObject
Dim filename As String
Dim filepath As String
Dim thetemplate As String
Dim picitem As NotesRichTextItem
Dim pic As NotesEmbeddedObject
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.document
Set view = db.GetView("vwWordTemplateLookup")
Set WrdTempNotesdoc = view.GetFirstDocument
If WrdTempNotesdoc Is Nothing Then
MsgBox("ERROR: Word Template file not found. Operation Aborted")
Exit Sub
End If
Set rtitem = WrdTempNotesdoc.GetFirstItem("TemplateMSWordDot")
If IsEmpty(rtitem.EmbeddedObjects) Then
MsgBox("ERROR: Word Template file not found. Operation Aborted")
Exit Sub
End If
ForAll embObj In rtitem.EmbeddedObjects
thetemplate = embObj.Source
Set wordobject = rtitem.GetEmbeddedObject(thetemplate)
filepath = "c:\"
filename = filepath & thetemplate
Call wordobject.ExtractFile(filename)
Exit ForAll
End ForAll
Dim wdApp As Variant
Dim wdDoc As Variant
Dim pictureControl1 As Variant
Dim bitmap1 As Variant
Set wdApp = CreateObject("Word.application")
wdApp.visible=True
Set wdDoc = wdApp.Documents.Add(filepath & thetemplate)
Set picitem = doc.Getfirstitem("foto")
If Not IsEmpty(picitem.Embeddedobjects) Then
Set pic = picitem.Embeddedobjects(0)
Call pic.Extractfile(filepath + pic.Name)
End If
Dim inhalt As String
inhalt = filepath + pic.Name
With wdDoc
.FormFields("name").result = doc.vorname(0) + " " + doc.nachname(0)
.FormFields("funktion").result = StrRight(doc.funktion(0), StrLeft(doc.funktion(0),1) + " ")
.FormFields("nummer").result = doc.arbeitsort(0)
.Shapes.AddPicture({"} & inhalt & {"})
End With
Call wdApp.activate
If Not IsEmpty(picitem.Embeddedobjects) Then
Kill filepath + pic.Name
End If
Vielen Dank & lg
Thierry
marschul:
Wie heißt denn die ausgelagerte Bilddatei? Kann es sein, dass pic.name keine gültige Extension liefert?
umi:
Hallo
Evtl. hilft es auch das Bild und das Template ins Temp Verzeichnis zu schreiben.
http://ozinisle.blogspot.com/2010/12/get-notes-temporary-directory-path-in.html
tburnens:
--- Zitat von: marschul am 08.02.12 - 09:48:31 ---Wie heißt denn die ausgelagerte Bilddatei? Kann es sein, dass pic.name keine gültige Extension liefert?
--- Ende Zitat ---
Lieber Marschul, Liebe Notes-Gemeinde
pic.name liefert zwar eine gültige Extension (.jpg, .bmp, .JPG,..), der Fehler lag aber sehr nahe. Das Problem war, dass die VBA-Syntax einen Filepfad in der Form AddPicture ( "C:\file.jpg" ) verlangt, bei der Anwendung in LotusScript aber zwingend AddPicture ( C:\file.jpg ) sein muss. Der Code funktioniert jedenfalls. :)
Vielen Dank für die raschen Anregungen!
lg Thierry
Navigation
[0] Themen-Index
Zur normalen Ansicht wechseln