unit Main_unit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComObj, Variants; //WordXP;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure VBA_vers_Lazarus_OnClick(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
//******************************************************************************
// Bouton 1
//******************************************************************************
procedure TForm1.VBA_vers_Lazarus_OnClick(Sender: TObject);
var
oApp: Variant;
oDoc: Variant;
oAutoText: Variant;
sourcedata :string;
begin
sourcedata := UTF8Decode(ExtractFilePath(Application.Exename) + '/pige/convention_export.xlsx');
oApp := CreateOleObject('Word.Application');
oApp.Visible := True;
oDoc := oApp.Documents.Open(UTF8Decode(ExtractFilePath(Application.Exename) + '/pige/Convention_diagnostic.docx'));
Showmessage('1');
//oDoc.MailMerge.OpenDataSource(UTF8Decode(ExtractFilePath(Application.Exename) + '/pige/convention_export.xlsx')); // Spécifiez la source de données ici
Showmessage('2');
//oDoc.MailMerge.OpenDataSource(UTF8Decode(ExtractFilePath(Application.Exename) + '/pige/convention_export.xlsx'), '', '', '', '', '', '', '', '', '', '', 'SELECT * FROM "Feuil1$"', '', '', '');
Showmessage('3');
//oDoc.MailMerge.OpenDataSource(ExtractFilePath(Application.Exename) + '/pige/convention_export.xlsx', '', '', '', '', '', '', '', '', '', '', '', 'SELECT * FROM Feuil1$', '', '', '');
Showmessage('4');
//oDoc.MailMerge.OpenDataSource(Name:=sourcedata, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True,AddToRecentFiles:=False, PasswordDocument:='', PasswordTemplate:='', WritePasswordDocument:='', WritePasswordTemplate:='', Revert:=False, Format:='', Connection:='', SQLStatement:='SELECT * FROM "Feuil1$"', SQLStatement1 :='');
Showmessage('5');
oDoc.MailMerge.Execute;
Showmessage('6');
oApp.Visible := True;
Showmessage('7');
end;
end.