https://bugs.documentfoundation.org/show_bug.cgi?id=172748
--- Comment #3 from [email protected] --- (In reply to Neil Roberts from comment #2) > Thinking about it a bit more, maybe it makes sense that the macros written > from scratch with LibreOffice don’t get saved into xlsm format. Presumably > the only reason you would want to save in that format is to give the > document to someone using Microsoft Office, but in that case the macros > presumably won’t work anyway because they would be written using > LibreOffice’s BASIC API. Arguably it’s not true that “no warning is given”, > because whenever you save in that format LibreOffice warns you that “this > document may contain formatting or content that cannot be saved in the > selected file format”. > > On the other hand it could be interesting to write macros in a new file in > VBA compatibility mode and have those saved in xlsm format. Sadly this > doesn’t seem to work. Just adding “Option VBASupport 1” at the top of the > script doesn’t seem to be enough to make the VBA functions available to the > script. However, if you apply the patch from comment #1, save the document > and then reload it the VBA API will be available and the macro will work. > > So maybe an alternative bug to fix would be to add a way to create macros in > VBA compatibility mode in a new document. Then the export code would > probably correctly handle exporting those and we could just say that it is > reasonable not to export macros that are not written in VBA mode. Hi Neil, You're right about the warning—I probably closed it once with the "Don't show again" checkbox checked, which is probably why I don't see it anymore. As for saving macros, I consider this a genuine bug involving content loss, and the target format is irrelevant. Macros are lost in the LibreOffice -> xlsm -> LibreOffice cycle; Excel plays no role. The user saves their file, opens it again in LibreOffice, and the macro code is gone. I believe this is data loss within the product itself, regardless of whether someone opens the file in Excel. The goal of my patch is to protect user data, and the warning is too general. As for saving macros in VBA-compatible mode, I don't think they interfere with each other; they complement each other rather than being alternatives. My patch fixes the immediate data loss, and VBA-compatible macros in a new document is a separate, useful improvement; I'm willing to file a separate bug for it. But this new fix alone will not fix the loss of macros when saving in a non-VBA-compatible mode. -- You are receiving this mail because: You are the assignee for the bug.
