// PROBLEM: Regardling of opening XLSX or XLS I get the same error message

skoroszyt_in := TsWorkbook.Create;// <--- added

skoroszyt_in.ReadFromFile(NazwaPliku);

for i :=0to skoroszyt_in.GetWorksheetCount()-1do

begin

arkusz_in := skoroszyt_in.GetWorksheetByIndex(i);

ShowMessage(arkusz_in.Name);

// Do something with MyWorksheet

end;

// Is it a method to close the workbook?

// skoroszyt_in.Destroy; // <--- ok, in principle, but...

skoroszyt_in.Free;// <--- better because it checks if skorosyt is nil

end;

You can also attach projects here - it would have the advantage that users reading this post later will be able to look at the project even if the external site does not longer exist. For uploading pack the .pas, .lfm, .lpr and .lpi files (as well as auxiliary data files needed (such as the .xls and xlsx files here) into a single zip file. You can upload using the "Attachments and other options". Please don't add any files generated by the compiler (such as .exe, .ppu etc).

And another wish from a non-Polish (?) person which would make debugging your code a bit easier: I would appreciate if you would translate your code to English - it's much easier to understand another programmer's code if the words are understood.