How to use VBA as a Calc library available to all documents

I have an Excel workbook which contains macros which in Excel are available to all my documents. I want to achieve the same in Calc so that I can use the documents on both Windows and Linux PCs.

I have tried with Tools >Macros and managed to create My Macros >Standard >Module2 with the VBA code, which seems to compile OK, but can’t find the macros to assign to shortcut keys.

It would be nice just to say “Use the .xlsm workbook as a library in Calc” but I can see anything that allows that.

Alternatively I would be happy to copy the VBA into a document-wide library (or module) in Calc and manage revisions manually.

The Excel VBA is not compatible with the StarBasic+LibreOffice_API environment.

The LibreOffice can run some VBA codes, but not all of them.

You must rewrite all of VBA macros based on the StarBasic+LibreOffice_API, and need store them in some Modules of the MyMacros - Standard Library.

Then they will be available for all of spreadsheet files what you open with the LibreOffice on your computer.

Yes, is better migrate macros from VBA to LOBasic.

Thank you for your replies. While researching the problem I have noticed this appears to the standard comment.
I have now noticed that VBA Activecell.row etc is not recognised in LOBasic. It seems LOBasic does not know about the activecell and there are subroutines posted for just extracting current cell info. Is that still the current situation?
I also note that my VBA code looks as though it has compiled but when a subroutine runs it will fail at a VBA Activecell statement as though it’s an interpretive Basic. If it’s interpretive, then why have a “compile” button?
I was hoping to find that the VBA conditional compilation instructions would allow me to have the VBA / LOBasic variations in the same file so that the code would run on both platforms. Is there a conditional compilation feature?

Forget the VBA if you want to work efficiently with the LO Macros. Rewrite your macros. The StarBasic is one of the supported programming languages what is appropriate to call the API functions of the LibreOffice. But you can call them from many other programming languages/environment too. Read: the API is independent from the language of the caller routine. (API: Application Programming Interface)

I never compiled the StarBasic+API macros.

You can get the active cell by this API calling:

Dim oDoc as object
Dim oCell as object

oDoc = ThisComponent
oCell = oDoc.getCurrentSelection

Thanks for your insight. It seems I am now on plan-b.Thanks for the code. I will take a closer look at the object model. Not my strongest subject…