[Calc] CurrentController is not available for function

Keyboard macros or custom scripts

[Calc] CurrentController is not available for function

Postby Bidouille » Wed Sep 13, 2017 7:18 pm

Hello,

Tested with AOO 4.1.3 and Win7 x64 Pro

I stored this function in a spreadsheet:
Code: Select all   Expand viewCollapse view
Function TEST(sCell)
    oDoc = thisComponent
    oCtrl 
= oDoc.currentController
    oSheet 
= oCtrl.activeSheet
    oCell 
= oSheet.getCellRangeByName(sCell)
    Test = sCell & " contains: " & oCell.string
End function

This works if I input this formula:
Code: Select all   Expand viewCollapse view
=TEST("C1")

But when I (re)load the document, I got: "Error, undefined object variable"

I don't know why CurrentController is void.
Functions must be calculated after document is loaded.
Did you think is a bug?
Attachments
function.ods
(9.48 KiB) Downloaded 5 times
User avatar
Bidouille
Volunteer
 
Posts: 198
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: [Calc] CurrentController is not available for function

Postby Villeroy » Wed Sep 13, 2017 7:46 pm

The document is calculated before rendering. There is no controller when this happens. Use ordinary references. =TEST(A1) refers to A1 on the same sheet as the formula cell.
If you need another type of referencing because you need access to the cell object you may consider this: https://forum.openoffice.org/en/forum/v ... =21&t=2762
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24257
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 5 guests