|
|
Mail Merge mit OpenOffice- #13197 in section [113145] |
Sec: |
(1) Allgemeines |
Von: |
Crusty kai@schmerzbefreit.de |
An: |
All |
Am/Um: |
15.03.2004 10:59:00 gelesen |
Hallo, ich bin gerade dabei OpenOffice zu automatisieren. Ich habe jedoch einige Probleme einen "Mail Merge" zu produzieren. Bisher habe ich es geschafft ein Textdokument (das Merge-Fields enthält) zu öffnen, ein Datenquelle (dbase) einzubinden und einen "Mail Merge" abzusetzen. Dabei werden soviele Dokumente erstellt, wie es Datensätze gibt, jedoch werden die "Merge-Fields" nicht mit den Daten ersetzt sondern bleiben leer. Hat jemand von euch eine Lösung oder einen Verdacht woran es liegen kann? Eventl. findet Ihr etwas im Code: *// OpenOffice-Dokument ist geladen... *// DataSource setzen oDatabaseContext = oSManager.createInstance("com.sun.star.sdb.DatabaseContext") oDataSource = oSManager.createInstance("com.sun.star.sdb.DataSource") cDataSourceName = "TestDataSource" *// Ist DataSource schon vorhanden? IF oDatabaseContext.hasByName(cDataSourceName) *// Ja, also wird sie gelöscht oDatabaseContext.revokeObject(cDataSourceName) ENDIF *// DataSource anlegen oDatabaseContext.registerObject(cDataSourceName, oDataSource ) oDataSource = oDatabaseContext.getByName(cDataSourceName) *// Verzeichnis der DataSource setzen oDataSource.setPropertyValue("URL", "sdbc:dbase:file:///c:/temp/test.dbf") *// Verbindung zu Datenquelle aufbauen oConnection = oDataSource.getConnection("","") && ohne Passwort und Username wird die Verbindung aufgebaut *// Zu erstellene Dokumente werden wo gespeichert... cOutputDir = "file:///c:/temp/result" oMerge = oSManager.createInstance("com.sun.star.text.MailMerge") COMARRAY(oMerge, 10) LOCAL ARRAY laPropertyValue[7] lnAIndex = 1 *// diesen Parameter braucht man nicht und mit diesem funktioniert es auch nicht... *!* laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" ) *!* laPropertyValue[lnAIndex].NAME = "DocumentURL" *!* laPropertyValue[lnAIndex].VALUE = "file:///C:/temp/result" *!* lnAIndex = lnAIndex +1 laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" ) laPropertyValue[lnAIndex].NAME = "DataSourceName" laPropertyValue[lnAIndex].VALUE = "TestDataSource" lnAIndex = lnAIndex +1 laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" ) laPropertyValue[lnAIndex].NAME = "ActiveConnection" laPropertyValue[lnAIndex].VALUE = oConnection lnAIndex = lnAIndex +1 laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" ) laPropertyValue[lnAIndex].NAME = "CommandType" laPropertyValue[lnAIndex].VALUE = 0 && Typ der Datenquelle (Tabelle) lnAIndex = lnAIndex +1 laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" ) laPropertyValue[lnAIndex].NAME = "Command" laPropertyValue[lnAIndex].VALUE = "TestDataSource" lnAIndex = lnAIndex +1 laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" ) laPropertyValue[lnAIndex].NAME = "OutputType" laPropertyValue[lnAIndex].VALUE = 2 && Mail-Merge wird in Dokumente geschrieben lnAIndex = lnAIndex +1 laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" ) laPropertyValue[lnAIndex].NAME = "OutputURL" laPropertyValue[lnAIndex].VALUE = cOutputDir lnAIndex = lnAIndex +1 laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" ) laPropertyValue[lnAIndex].NAME = "FileNamePrefix" laPropertyValue[lnAIndex].VALUE = "result" lnAIndex = lnAIndex +1 oMerge.Execute( @laPropertyValue )
|
|
|
|