Description: I have some xlsm files that contain macros that need to have Greek characters. After opening and saving the file with libreoffice calc the Greek characters will change to "?" destroying the macro. Maybe valid for any non Latin character. Whe the file is in ods format it seems to be function ok. Steps to Reproduce: 1.Write a BASIC macro containing Greek characters in an xlsm file 2.Open and save the file with calc Actual Results: Every Greek Characher is changed to "?" Expected Results: Every Greek Characher should NOT be changed to "?" Reproducible: Always User Profile Reset: Yes OpenGL enabled: Yes Additional Info: Version: 7.2.7.2 / LibreOffice Community Build ID: 20(Build:2) CPU threads: 12; OS: Linux 5.18; UI render: default; VCL: gtk3 Locale: el-GR (en_US.UTF-8); UI: en-US 7.2.7-3 Calc:
Created attachment 181141 [details] The text of the actual Macro The text of the actual Macro
Created attachment 181142 [details] the text of the macro after saving the text of the macro after saving
Can't reproduce. If I save the "actual Macro" attachment, which is UTF-8, as file, open it in an editor displaying it fine, and copy-paste it into Calc's BASIC editor (or import it there as BASIC file), save the document, reload it, open the BASIC editor again it's still fine. Probably the original .xlsm files have the macros encoded in some text encoding other than UTF-8, i.e some code page like Windows-1252 or so. Please attach such sample file.
I have done what you describe multiple times. I am attaching the actual file.
Created attachment 181143 [details] The actual xlsm file The actual xlsm file
*** This bug has been marked as a duplicate of bug 75263 ***
(In reply to Alexander from comment #5) > Created attachment 181143 [details] > The actual xlsm file FTR: the said attachment is not the "actual" file, it is what was *destroyed* by LibreOffice 7.2 (not yet having the fix that appeared in to-be-released-soon 7.4, and so saving VBA modules in a hardcoded Windows-1252). To allow others to reproduce the *reported problem* (as opposed to "look at the results which you can't reproduce yourself"), the *original*, correct file is needed, which others can open, see the Greek characters, save locally, and see the breakage. Hope this helps you next time. Thank you for filing this bug!
Created attachment 181146 [details] The correct xlsm file unopened from Libreoffice The correct xlsm file unopened from Libreoffice
(In reply to Alexander from comment #8) Thanks! Indeed, it has the problem in 7.3, and is fixed in 7.4. By the way, LibreOffice now works better in that regards than MS Office: the latter will destroy the macros on any non-Greek locale - e.g., on my Russian locale it shows opened the macro this way: > Option Explicit > > Public Function GreekToLatin(celltxt As Variant) As String > Dim i As Long, j As Long > > Dim txt As Variant > > txt = Application.WorksheetFunction.Trim(celltxt) > > If Len(txt) Then > 'МефбфспрЮ уе режЬ > txt = LCase(txt) > > 'БнфйкбфЬуфбуз т ме у > txt = Replace(txt, "т", "у") > > 'БнфйкбфЬуфбуз 'пх' уе 'oy' ==> (9) > txt = Replace(txt, "ьх", "oy") > txt = Replace(txt, "ьы", "oy") > txt = Replace(txt, "пы", "oy") > > 'БцбЯсеуз фьнщн клр > Dim MeTonous As Variant, Atona As Variant > MeTonous = Array("Ь", "Э", "Ю", "Я", "ь", "э", "ю", "ъ", "ы", "А", "а") > Atona = Array("б", "е", "з", "й", "п", "х", "щ", "й", "х", "й", "х") > > For i = 0 To UBound(MeTonous) > txt = Replace(txt, MeTonous(i), Atona(i)) > Next > > 'БнфйкбфЬуфбуз дйциьггщн (бх, ех, зх) ме (av, ev, iv)==> (3) > Dim Difth As Variant, tov As Variant, tof As Variant > Difth = Array("бх", "ех", "зх") > tov = Array("в", "г", "д", "ж", "л", "м", "н", "с", _ > "б", "е", "з", "й", "п", "х", "щ") > > For i = 0 To UBound(Difth) > For j = 0 To UBound(tov) > txt = Replace(txt, Difth(i) & tov(j), Left(Difth(i), 1) & "v" & tov(j)) > Next > Next > > 'БнфйкбфЬуфбуз дйциьггщн (бх, ех, зх) ме (af, ef, if)==>(4) > tof = Array("и", "к", "о", "р", "у", "ф", "ц", "ч", "ш") > > For i = 0 To UBound(Difth) > For j = 0 To UBound(tof) > txt = Replace(txt, Difth(i) & tof(j), Left(Difth(i), 1) & "f" & tof(j)) > Next > Next > 'јфбн еЯнбй фЭлпт фзт лЭозт ==> (4) > For i = 0 To UBound(Difth) > txt = Replace(txt & " ", Difth(i) & " ", Left(Difth(i), 1) & "f ") > Next > > 'Фп 'мр' уфзн бсчЮ гЯнефбй 'b' ==> (5) > txt = Replace(" " & txt, " мр", " b") > > 'Фп 'мр' уфп фЭлпт гЯнефбй 'b' ==>(7) > txt = Replace(txt & " ", "мр ", "b ") > > 'БнфйкбфЬуфбуз ухмрлькщн > Dim SimplocaGr As Variant, SimplocaLn As Variant > SimplocaGr = Array("гг", "гч", "го", "пх") > SimplocaLn = Array("ng", "nch", "nx", "ou") > For i = 0 To UBound(SimplocaGr) > txt = Replace(txt, SimplocaGr(i), SimplocaLn(i)) > Next > > 'БнфйкбфЬуфбуз хрьрпйрщн чбсбкфЮсщн > Dim Greek As Variant, Latin As Variant > Greek = Array("б", "в", "г", "д", "е", "ж", "з", "и", "й", "к", _ > "л", "м", "н", "о", "п", "р", "с", "у", "ф", "х", _ > "ц", "ч", "ш", "щ") > Latin = Array("a", "v", "g", "d", "e", "z", "i", "th", "i", "k", _ > "l", "m", "n", "x", "o", "p", "r", "s", "t", "y", _ > "f", "ch", "ps", "o") > > For i = 0 To UBound(Greek) > txt = Replace(txt, Greek(i), Latin(i)) > Next > > txt = Trim(txt) > 'МефбфспрЮ рсюфпх чбсбкфЮсб уе кецблбЯп (Proper) > txt = Application.WorksheetFunction.Proper(txt) > GreekToLatin = txt > End If > End Function i.e., it simply treats the stored Windows-1253 encoding as Windows-1251. In LibreOffice, which uses Unicode also for macros, it will import, show and export the macros correctly (with a caveat that, since MS formats use non-Unicode encoding, if you use some character not representable in the original macro encoding, it will still convert to ? - so you can't have both Greek and Cyrillic characters in one MS VBA macro).