Open and read an Excel spreadsheet by Lazarus Using OLE

Asked

Viewed 818 times

0

The code below works perfectly in Delphi, but when 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 Lazarus, it is even included in a lib of common use for both, and in Lazarus this occurs.

What I’m missing?

  • What is the exception?

  • Almox_importaitem project raised class exception 'External: ? '. At 7FFE8180F20 In the debugger’s Assembler window: 00007FFEE8180E0 eb0c jmp 0x7ffee8180eee <ntdll! Rtlpntmaketemporarykey+398> I checked if I am declaring Units Comobj, and it is OK.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.