[Solved][Calc] CurrentController not available for function

Keyboard macros or custom scripts

[Solved][Calc] CurrentController 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 164 times
Last edited by Bidouille on Tue Jun 16, 2020 11:56 am, edited 4 times in total.
User avatar
Bidouille
Volunteer
 
Posts: 366
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 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28798
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved][Calc] CurrentController not available for funct

Postby Bidouille » Fri Jun 22, 2018 2:48 pm

I bump this thread.

Seems that document works perfectly with LibO.
User avatar
Bidouille
Volunteer
 
Posts: 366
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: [Calc] CurrentController not available for function

Postby Villeroy » Fri Jun 22, 2018 11:39 pm

Not with LO5.4
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28798
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Calc] CurrentController not available for function

Postby Bidouille » Mon Jun 25, 2018 10:04 am

no_problemo.gif
Click here to see animation
User avatar
Bidouille
Volunteer
 
Posts: 366
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: [Calc] CurrentController not available for function

Postby Villeroy » Mon Jun 25, 2018 10:46 am

Strange.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28798
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Calc] CurrentController not available for function

Postby JohnSUN-Pensioner » Thu May 28, 2020 3:10 pm

It is possible that in LiO 5.4 this option was incorrectly processed
UDFormula.png
UDFormula.png (7.42 KiB) Viewed 885 times

(now, in 6.4.3.2 I was not able to repeat this trick) - in the animated GIF we see not the result of the function recalculation, but the stored value.

Anyway, or your
Code: Select all   Expand viewCollapse view
If (isNull (oCtrl)) then Exit function
or
Code: Select all   Expand viewCollapse view
On Error Resume Next
combined with the first row
Code: Select all   Expand viewCollapse view
TEST = "Press Ctrl+Shift+F9"

allows to partially solve the problem.
I am sure that everyone (except novice users) will agree that a complete solution to this problem is a complete rejection of the use of such macros.
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 824
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: [Calc] CurrentController not available for function

Postby Lupp » Thu May 28, 2020 11:24 pm

See also:
ask90364activeSheet_1.ods
(11.08 KiB) Downloaded 39 times
On Windows 10: LibreOffice 7.0 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2936
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Calc] CurrentController not available for function

Postby Bidouille » Tue Jun 16, 2020 11:55 am

JohnSUN-Pensioner wrote:now, in 6.4.3.2 I was not able to repeat this trick

Thanks for this new test.

JohnSUN-Pensioner wrote:
Code: Select all   Expand viewCollapse view
If (isNull (oCtrl)) then Exit function
or
Code: Select all   Expand viewCollapse view
On Error Resume Next
combined with the first row
Code: Select all   Expand viewCollapse view
TEST = "Press Ctrl+Shift+F9"

allows to partially solve the problem.

Well I can run UNO command to recalculate: viewtopic.php?f=45&t=54868
User avatar
Bidouille
Volunteer
 
Posts: 366
Joined: Mon Nov 19, 2007 10:58 am
Location: France


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 3 guests