[Solved] Calc Calculation modes?

The Application Programming Interface and the OASIS Open Document Format

[Solved] Calc Calculation modes?

Postby alavarre » Fri Apr 29, 2011 11:24 pm

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
alavarre
 
Posts: 16
Joined: Thu Feb 12, 2009 2:22 am

Re: Calc Calculation modes?

Postby Charlie Young » Sat Apr 30, 2011 12:23 am

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   Expand viewCollapse view
ThisComponent.enableAutomaticCalculation(True/False)
Apache OpenOffice 4.1.1
Windows XP
User avatar
Charlie Young
Volunteer
 
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Calc Calculation modes?

Postby alavarre » Sat Apr 30, 2011 12:46 am

Woohoo! Thanks!

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

http://documentation.openoffice.org/HOW_TO/various_topics/VbaStarBasicXref.pdf
Porting Excel/VBA to
Calc/StarBasic 2004

http://wiki.services.openoffice.org/w/images/1/1a/0606MG-DifferencesInUseCalcExcel.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
alavarre
 
Posts: 16
Joined: Thu Feb 12, 2009 2:22 am

Re: Calc Calculation modes?

Postby Charlie Young » Sat Apr 30, 2011 1:13 am

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_TO/various_topics/VbaStarBasicXref.pdf
Porting Excel/VBA to
Calc/StarBasic 2004

http://wiki.services.openoffice.org/w/images/1/1a/0606MG-DifferencesInUseCalcExcel.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   Expand viewCollapse view
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   Expand viewCollapse view
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
User avatar
Charlie Young
Volunteer
 
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Calc Calculation modes?

Postby alavarre » Sat Apr 30, 2011 1:23 am

> 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
alavarre
 
Posts: 16
Joined: Thu Feb 12, 2009 2:22 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest