[Solved] Calc Calculation modes?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
alavarre
Posts: 16
Joined: Thu Feb 12, 2009 2:22 am

[Solved] Calc Calculation modes?

Post by alavarre »

What is the UNO equivalent of the following VBA statement:

Application.Calculation = xlCalculationManual

I've found that VBA Application. is replaced with UNO ThisComponent. I've installed both MRI and the ObjectInspector but haven't yet found how to get the properties and interfaces for the ThisComponent service...

I've spent the last four days with StarOffice 8 Programming Guide for BASIC learning about UNO, the API, Getting started...

But this one eludes me and Google... :-(

Thanks in advance.
Best regards, Andy
http://genietvanhetleven.blogspot.com/
Last edited by Hagar Delest on Sat Apr 30, 2011 5:58 pm, edited 1 time in total.
Reason: tagged [Solved].
OOo 3.0.X on openSuse 11
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Calc Calculation modes?

Post by Charlie Young »

alavarre wrote:What is the UNO equivalent of the following VBA statement:

Application.Calculation = xlCalculationManual

I've found that VBA Application. is replaced with UNO ThisComponent. I've installed both MRI and the ObjectInspector but haven't yet found how to get the properties and interfaces for the ThisComponent service...

I've spent the last four days with StarOffice 8 Programming Guide for BASIC learning about UNO, the API, Getting started...

But this one eludes me and Google... :-(

Thanks in advance.
Best regards, Andy
http://genietvanhetleven.blogspot.com/

Code: Select all

ThisComponent.enableAutomaticCalculation(True/False)
Apache OpenOffice 4.1.1
Windows XP
alavarre
Posts: 16
Joined: Thu Feb 12, 2009 2:22 am

Re: Calc Calculation modes?

Post by alavarre »

Woohoo! Thanks!

Is this all in your head or is there a web (or other) source? I've found:

http://documentation.openoffice.org/HOW ... icXref.pdf
Porting Excel/VBA to
Calc/StarBasic 2004

http://wiki.services.openoffice.org/w/i ... cExcel.pdf
Differences in Use between
Calc and Excel

http://www.business-spreadsheets.com/vba2oo.asp
VBA to OO Basic Converter
Convert VBA to OpenOffice Basic

But none offered a solution.

Again, thank you very much,
Andy

Best regards, Andy
OOo 3.0.X on openSuse 11
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Calc Calculation modes?

Post by Charlie Young »

alavarre wrote:Woohoo! Thanks!

Is this all in your head or is there a web (or other) source? I've found:

http://documentation.openoffice.org/HOW ... icXref.pdf
Porting Excel/VBA to
Calc/StarBasic 2004

http://wiki.services.openoffice.org/w/i ... cExcel.pdf
Differences in Use between
Calc and Excel

http://www.business-spreadsheets.com/vba2oo.asp
VBA to OO Basic Converter
Convert VBA to OpenOffice Basic

But none offered a solution.

Again, thank you very much,
Andy

Best regards, Andy
The main API docs are here.

This one is slightly tricky. There is a ThisComponent.isAutomaticCalculationEnabled, which one would normally think is a property that could be set directly by

Code: Select all

ThisComponent.isAutomaticCalculationEnabled = True/False
but it seems isAutomaticCalculationEnabled is actually a method, and though it will return the correct boolean state value, the EnableAutomaticCalculation method is to be used to set it, though one could also use dispatcher calls

Code: Select all

sub setAutoCalculate(calcstate as Boolean)

	dim document   as object
	dim dispatcher as object

	document   = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

	dim args1(0) as new com.sun.star.beans.PropertyValue
	args1(0).Name = "AutomaticCalculation"
	args1(0).Value = calcstate

	dispatcher.executeDispatch(document, ".uno:AutomaticCalculation", "", 0, args1())

end sub

That is a bit clumsy compared to the other method.
Apache OpenOffice 4.1.1
Windows XP
alavarre
Posts: 16
Joined: Thu Feb 12, 2009 2:22 am

Re: Calc Calculation modes?

Post by alavarre »

> The main API docs are [here].

Ah yes, I had found that also, very arcane... I was hoping for something more direct. The [Porting...]
doc is good as far as it goes, but as noted doesn't go far enough. The MRI and Inspector may render the API but again have a learning curve...

> This one is slightly tricky. There is a ThisComponent.isAutomaticCalculationEnabled,
>...
>That is a bit clumsy compared to the other method.

Indeed...

Thanks again, back to doing homework. Have a great weekend.

Kind regards, Andy
OOo 3.0.X on openSuse 11
Post Reply