Can I make a LO Calc ods macro work in Excel? Says file is corrupted

Greeting!

I need to create a macro in ODS that will work in Excel if someone uses Office instead of LibreOffice.

So far, I created a button in LO Calc and recorded a macro, then attached that macro to the button. The file is saved in ODS format.

Opening it in another computer with LO, sometimes the button isn’t clickable, the click goes right through and is instead selecting the cells under it (now above it, it seems).

Opening the file in Excel (not tested myself, but a customer sent a screenshot) it throws an error about corrupted file.

Cans someone enlightens me please? Is this at all possible?
In the same topic, if I create a form to fill out on a sheet to add structured data on another, should this work in Excel if created in LO ODS?

I never really pushed that far with LO. I appreciate any insights you might have :slight_smile:

LO API macros will not run in Excel. (Post a request to the Microsoft :slight_smile: )
Some Excel VBA macros can run in LO.

1 Like

Oh… So just to make sure I understand: Office cannot understand any LO macro either in ods or xls file format? Therefore, if I create files exclusively in LO, people (read: standard business folks using Windows and Office) that open my files to use macros would need to have both Office and LibreOffice installed?

All this started with the fact that I need a sheet locked because people don’t understand how sheets work. I want those people to enter basic data and be able to easily sort alphabetically.

The macro unlock the protected sheet, sort then re-lock to ensure the “end user” doesn’t mess with formulas. Except using Microsoft thing, is there an alternative for me? Does Collabora or a paid non-Microsoft software would work?

Post a request to the Microsoft

Haha, let’s be honest, Microsoft really doesn’t care about compatibility and helping end users :wink:

Some Excel VBA macros can run in LO.

I heard, but I need the other way around

(I’ll go off topic here but you seem quite familiar with LO seeing your profile, do you know if the donations to The Document Foundation go to fund the development of LO? I know people think donating to Mozilla funds Firefox but that is not the case, just making sure)

If you must develop Excel macros in Excel file format, then you must BUY an Excel. Only the Excel is compatible with the Excel (less or more :smiley: )
Or just develop LO macros in the international Standard ODF file format, because the LO is free for everyone.

Note: never was and never will be 100% compatibility between the file types, between the macro systems, between the different applications. The LibreOffice is NOT a clone of the MS office.

The LibreOffice is NOT a clone of the MS office.

I understand that. I just need to create macros with LO and make them work with Office. Because let’s face it, a third party user in a company won’t try and install LO just for a file or two a random guy created, they will just ask for Office stuff or go look elsewhere.

I’ll check and see if I can make Office works with wine and get a cheap license somewhere if that’s my only option.

I appreciate the time you took with me today <3

Someone should update the wiki so it’s a bit clearer. A friend sent me this link to the wiki: https://wiki.documentfoundation.org/Feature_Comparison:LibreOffice-_Microsoft_Office

Under “Macro scripting languages” it says “Import and export of Visual Basic for Applications (VBA)”. Reading this, I would suspect LO to be able to import VBA from Office and export/save VBA in a way that is also compatible with Office :thinking:

At first this is only a set of options to allow an VBA-Macro to be kept and saved back, if you use MS-files. (Otherwise a file could just loose the VBA-Macros.)
.
On a second stage, there is a flag for VBA -compatibility, so LibreOffice can try to run an VBA-Macro. This is quite limitied compared to the wide range both the VBA-Modules or UNO offer to a programmer. For databases there is a similiar approach Access2Base… But this won’t halp in your case, as you already stated:

See:
https://help.libreoffice.org/latest/en-US/text/sbasic/shared/vbasupport.html

Then you MUST create your macros twice. One for the LO - based on the LO API functions -, and secondary: in M$ VBA in an Excel file (in the Excel application!): then you can try if it works in Excel or not. (You must use same version of the Excel as the users use the macros and the Excel file.)

The LibreOffice Application Programming Interface (API) and the MS Visual Basic for Applications (VBA) are basicly different things…

1 Like

See this message.
The developer can create documents with macros (of any complexity) that will work in both LibreOffice and Microsoft Office. But of course, this requires certain skills.

2 Likes

I’m going to give it a try, thanks for the tip! Any idea if I should save the end file as ODS or XLS? (It might save me some times if you know lol, if not it’s alright :wink: )

Theses:

  1. The file must be in .xlsm format (or .xltm if you are creating a template). Macros must be written initially in Excel VBA and tested in both Excel and Calc.
  2. The presence of UserForm(s) (Excel), Dialog(s) (Calc) significantly increases the complexity of creating a document.

If you upload your file with macros and explain how to use it, then I can try to show you how it works in LibreOffice and Microsoft Office.

1 Like