procedure TForm1.MailMerge;
var
MMerge, MMArgs: OleVariant;
Dokumentenname_Old, Dokumentenname_New, LoadDok, OOoDB:
string;
begin
If Filename = '
'
then
begin
Messagedlg('
Dokument wurde nicht geladen', mtError, [mbOK], 0);
exit;
end;
OOoDB := '
MVASpenden';
Dokumentenname_Old := Filename;
Dokumentenname_New := '
Test';
LoadDok := '
D:\Tmp\'+Dokumentenname_New+'
0'+'
.odt';
MMArgs := VarArrayCreate([0, 6], varVariant);
MMerge := OOo.oMerge;
MMArgs[1] :=OOo.NamedValue('
DocumentURL', OOo.ToOOPfad(Dokumentenname_Old));
MMArgs[0] :=OOo.NamedValue('
DataSourceName', OOoDB);
// 0=Tabellen 1=Abfragen 2=SQL-Abfragen
MMArgs[2] := OOo.NamedValue('
CommandType', 0);
MMArgs[3] := OOo.NamedValue('
Command', '
Spenden');
// Ausgabe an 1=Drucker 2=Datei
MMArgs[4] := OOo.NamedValue('
OutputType', 2);
MMArgs[5] := OOo.NamedValue('
OutputURL', OOo.ToOOPfad('
D:\Tmp'));
MMArgs[6] := OOo.NamedValue('
FileNamePrefix', Dokumentenname_New);
MMerge.execute(MMArgs);
OOo.Open(LoadDok);
end;