Is there a way after programmatically opening a cwk file to programmatically determine whether the file is a word processing file (text) or a spreadsheet file? All the files are one or the other

I want to loop through a collection of cwk files. All the files are either word processing (text) files or spreadsheet files. Is there a way after opening the file programmatically to determine whether the cwk file is a text file (word processing) or a spreadsheet file. I want to save the text files as odt and close without saving the spreadsheet files. I am an experienced Excel VBA programmer. Looping through and opening should be straightforward from what I have read so far.

Suppose after I have opened the cwk file I try and execute a “save as” odt type. If the file is a text (word processing) file it will execute correctly. If it a spreadsheet type it will cause an error condition. If I trap the error condition I should be able to accomplish what I want. Will this work?
I have the code that creates the file name with full path as a string. I am hung up on the call to the API to open the file which has a .cwk extension. I just want to open it and then save it as an .odt file.
Any help would be appreciated.

According to this thread on the LO filter used for ClarisWorks / AppleWorks files it does not support the spreadsheet type of document. In my answer in that thread I provide a link to work done by Terrence Curran on trying to reverse-engineer the CWK format. I would start by looking at the source code of the work he has done.

Thanks for the link to Curran’s work. I see he is opening and closing the files with Applescript which could be modified and embedded in Libreoffice basic. I have very little knowledge of Applescript. I was hoping to do the opening and saving or closing staying within Libreoffice basic. This is much more complicated than I had imagined as compared with doing something similar in Excel VBA.
Thanks again for the link