How can I check by Calc function if some file is open at this moment?

I need to have Calc function to determine if some file is open at this moment. For example function
fnIsFileOpen(“C:/xxx.txt”) should return TRUE if file C:/xxx.txt was open and FALSE if it wasn’t open when function was called.

Do you mean “was open with LibreOffice” or “was open with any application (i.e. Notepad)”? In the first case, look at the code TaskonDesktop() function from the standard library Tools, the Misc module. In the second case, just try to open it and analyze the error code