The code below works perfectly in Delphi, but when I ported to Lazarus, the code compiles without problems, but at the time of execution an exception occurs and the program is closed.
function TFMain.AbrePlanilha(NomePlan: String): Boolean;
begin
Try
Result := False;
if not FileExists(NomePlan) Then
exit;
Mensagem('Abrindo excel, aguarde...');
ExcelApp := CreateOLEObject('Excel.Application'); // <- até aqui OK
// O erro ocorre aqui abaixo.
// ==============================================
ExcelPlan := ExcelApp.WorkBooks.Open(NomePlan);
// ==============================================
Mensagem('Planilha Excel ' + NomePlan + ' aberta OK!');
Result := True;
Update;
Finally
End;
end;
The curious thing is that the code is the same for Delphi and for Lazarus, it is included in a common use lib for both, and in Lazarus this occurs.
What am I letting go of?