https://bugs.documentfoundation.org/show_bug.cgi?id=79588

--- Comment #11 from Richard Bruce Baxter <[email protected]> ---
This issue is still occurring on LibreOffice 5.3.0.3 (x64). I have attached the
following example to demonstrate the bug;
libreOfficeBug-macroFunctionsNotEvaluatedUponLoad.ods.

To Replicate;
1. Ensure that libreOffice Macro security is set to Low/Medium (libreOffice -
Tools - options - security - Macro security - Medium)
2. Open document (e.g. libreOfficeBug-macroFunctionsNotEvaluatedUponLoad.ods) -
select enable Macros

Note that libreOfficeBug-macroFunctionsNotEvaluatedUponLoad.ods is a very
simple example. In cell A1 it contains the text "Some Text". In Cell B1 it
contains the forumla =GETCELL("Sheet1", "A1"). In LibreOffice - Tools - macros
- organise macros - libreoffice basic -
libreOfficeBug-macroFunctionsNotEvaluatedUponLoad.ods - [myCalcFunctions] -
Module1 it contains the following code*;
        REM  *****  BASIC  *****
        Sub Main
        End Sub
        Function GETCELL(sheetName As String, cellReference As String)
                oSheet = ThisComponent.Sheets.getByName(sheetName)
                oCell = oSheet.getCellRangeByName(cellReference).String
                'Msgbox(oCell)
                GETCELL = oCell
        End Function

Expected Behaviour;
Libreoffice executes user defined macro functions upon document load (cell B1
should read "Some Text").

Actual Behaviour;
Libreoffice doesn't execute user defined macro functions upon document load
(all cell formulae containing references to these functions are evaluated as
"#NAME?". Cell B1 therefore displays "#NAME?")

Workaround (to reload macros for cells);
1. Open document (e.g. libreOfficeBug-macroFunctionsNotEvaluatedUponLoad.ods) -
select enable Macros
2. LibreOffice - Tools - macros - organise macros - libreoffice basic -
libreOfficeBug-macroFunctionsNotEvaluatedUponLoad.ods - [myCalcFunctions] -
Module1 - Edit (open the editor)
{or LibreOffice - Tools - macros - edit macros -
libreOfficeBug-macroFunctionsNotEvaluatedUponLoad.ods - [myCalcFunctions] -
Module1}
3. edit cell - space - backspace - enter (force LibreOffice to re-evaluate the
cell formula).

Non-workaround;
A previous workaround suggested in this bug report thread was to move the macro
function definition from 'libreOfficeBug-macroFunctionsNotEvaluatedUponLoad.ods
- [myCalcFunctions] - Module1' to 'My Macros & Dialogs - Standard - Module1'.
This however is a non-solution, as standard functions may be called before the
document's sheets are loaded, depending upon how the document has been saved
(NB there appears to be another bug relating to inconsistent saving of a
document as to whether the standard macros will be executed before or after its
sheets are loaded). I have provided an alternate example to demonstrate this
bug. To replicate;
1. Open libreOffice Calc
2. LibreOffice - Tools - macros - organise macros - libreoffice basic - My
Macros & Dialogs - Standard - Module1 - Edit (add the code above*)
3. Close LibreOffice
4. Open
libreOfficeBug-macroFunctionsNotEvaluatedUponLoad-withoutEmbeddedMacro.ods -
select enable Macros
5. Note that the following error is thrown; "Basic Runtime error. Property or
method not found: Sheets."

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to