Autor Thema: Bild per Script nach Word exportieren - Fehler: Grafikfilter konnte File nicht..  (Gelesen 3445 mal)

Offline tburnens

  • Frischling
  • *
  • Beiträge: 2
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

Offline marschul

  • Senior Mitglied
  • ****
  • Beiträge: 280
  • Geschlecht: Männlich
Wie heißt denn die ausgelagerte Bilddatei? Kann es sein, dass pic.name keine gültige Extension liefert?
Gruß
Marco

Ich, der ich weiß, mir einzubilden, dass ich weiß, nichts zu wissen, weiß, dass ich nichts weiß. (Sokrates)
Keiner ist unnütz, er kann immer noch als schlechtes Beispiel dienen. (unbekannt)

Offline umi

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.062
  • Geschlecht: Männlich
  • one notes to rule'em all, one notes to find'em....
    • Belsoft AG
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
Gruss

Urs

<:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jegliche Schreibfehler sind unpeabischigt
http://www.belsoft.ch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:>

Offline tburnens

  • Frischling
  • *
  • Beiträge: 2
Wie heißt denn die ausgelagerte Bilddatei? Kann es sein, dass pic.name keine gültige Extension liefert?


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

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz