Description: When modifying and saving any code in my LibreOffice Document, changing the background color of a cell using RGB values results in the cell displaying an incorrect color. In my example, setting a cell's background color to RGB(0, 0, 255) turns it blue as expected, but after changing or commenting out any line of code and saving, the cell's background color changes to red instead of the specified blue. Calculating the value myself, so using just 255 instead of RGB(0,0,255) in this scenario is a working workaround Steps to Reproduce: 1. Open ColorDemo document 2. Run SetCellColor function 3. Observe result (cell turns blue) 4. Comment out the SetSheetRef function and save 5. Run SetCellColor again 6. Observe difference in results Actual Results: After saving the change in the macro code, the Subroutine starts to turn cell A1 Red Expected Results: Sub should continue to turn cell Blue Reproducible: Always User Profile Reset: Yes Additional Info: Version: 24.2.4.2 (X86_64) / LibreOffice Community Build ID: 51a6219feb6075d9a4c46691dcfe0cd9c4fff3c2 CPU threads: 16; OS: Windows 10.0 Build 19045; UI render: Skia/Vulkan; VCL: win Locale: de-DE (de_DE); UI: en-US Calc: CL threaded
Created attachment 195346 [details] Demo file
SetCellColor and SetSheetRef functions reside in BACnet_Template_Makros - Modules - SC_RS_Modules I reproduce with the file all the way to 3.5.0, no need to save in between, just run SetCellColor immediately after commenting out SetSheetRef. However, I can not reproduce in a new file. So I think something in your macros is interfering with this. As I spent already quite a lot of time on this, I would appreciate if you investigated it further to find out what in your collection of macros is the reason for this.
(In reply to Buovjaga from comment #2) > SetCellColor and SetSheetRef functions reside in BACnet_Template_Makros - > Modules - SC_RS_Modules > > I reproduce with the file all the way to 3.5.0, no need to save in between, > just run SetCellColor immediately after commenting out SetSheetRef. > > However, I can not reproduce in a new file. So I think something in your > macros is interfering with this. As I spent already quite a lot of time on > this, I would appreciate if you investigated it further to find out what in > your collection of macros is the reason for this. I just managed to reproduce the bug. As it turns out, the problem is opening an excel xlsm document with libreoffice and saving it as .ods It should be possible to reproduce by doing the following: 1. Create a new Excel Document 2. Record a Macro (I just changed A1 to blue) 3. Save as .xlsm 4. Open document with Libreoffice Calc (Right click -> Open with -> Libreoffice) 5. Replace the macro with the libreoffice equivalent And now the Bug will happen. If you open the document and run it, the cell turns blue. If you change anything in the code (e.g. add a space at the end of the comment), the macro starts turning the cell red. I did not manage to reverse this issue. Deleting the module and creating a new one in the standard location did nothing. For reference, here is the macro: 'Sets the Background of Cell A1 to Blue 'it will start turning cell A1 to Red after modifying the code anyhow. Even adding a space at the end of this comment does the trick (no saving needed) Sub SetCellColor oSheet = ThisComponent.CurrentController.ActiveSheet oSheet.getCellByPosition(0,0).CellBackColor = RGB(0, 0, 255) End sub As a Workaround I wrote this Macro: Function RGBToVal(r As Integer, g As Integer, b As Integer) As Long RGBToVal = (r * 65536) + (g * 256) + b End Function And Replaced "RGB(" with "RGBToVal(" using Ctrl+H. Let me know if you need any more info
(In reply to KosulinLeonidas from comment #3) > I just managed to reproduce the bug. > As it turns out, the problem is opening an excel xlsm document with > libreoffice and saving it as .ods Can you attach such a minimal xlsm document? Thanks.
Created attachment 196217 [details] Minimal xlsm Document 1. Open Minimal xlsm Doc 2. Paste following macro into module1 3. Macro turns cell a1 red instead of blue Sub SetCellColor oSheet = ThisComponent.CurrentController.ActiveSheet oSheet.getCellByPosition(0,0).CellBackColor = RGB(0, 0, 255) End sub
(In reply to Buovjaga from comment #4) > (In reply to KosulinLeonidas from comment #3) > > I just managed to reproduce the bug. > > As it turns out, the problem is opening an excel xlsm document with > > libreoffice and saving it as .ods > > Can you attach such a minimal xlsm document? Thanks. It seems like saving it as .ods isn't even necessary, nor is it for the xlsm doc to have any macros in it. I recorded a macro just for it to create a module and deleted it right after. It seems like opening the xlsm document with libreoffice breaks something but I can't figure out why. Just opening the document with libreoffice, pasting the other macro and running it already reproduces the bug
Created attachment 196218 [details] xlsm with libreoffice macro This one you can just open with libreoffice and instantly run the macro. It will turn the cell red instead of blue. No need to change anything at all
(In reply to KosulinLeonidas from comment #7) > Created attachment 196218 [details] > xlsm with libreoffice macro > > This one you can just open with libreoffice and instantly run the macro. It > will turn the cell red instead of blue. No need to change anything at all Thanks. It's in VBAProject - Modules. Already seen in 3.5.0.