| View previous topic :: View next topic |
| Author |
Message |
marc_the_french Guest
|
Posted: Wed Nov 26, 2003 2:46 am Post subject: impossible to update chart by changing data |
|
|
I try to update the a chart by changing data in a macro, but it just doesn't work: I mean nothing is updated.
I use this code:
dim param_graph(3) as new com.sun.star.beans.PropertyValue
param_graph(0).Name = "Name"
param_graph(0).Value = object_graph
param_graph(1).Name = "Range"
' range of cells to update the chart *****
param_graph(1).Value = val_range
param_graph(2).Name = "ColHeaders"
param_graph(2).Value = false
param_graph(3).Name = "RowHeaders"
param_graph(3).Value = false
dispatcher.executeDispatch(document, ".uno:ChangeChartData", "", 0, param_graph())
If I try to record this with the macro recorder, I get the same code. When I run again this code (made by the recorder, but with change of range !), it's the same result: nothing is updated. Why ???
Can anyone help me ? |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
marc_the_french Guest
|
Posted: Wed Nov 26, 2003 6:32 am Post subject: reply to SergeM |
|
|
The cells range grows each day (I have to record the cheques I paid each day). When the new cells are inserted in the sheet, I run a macro :
- to select the new cells range (but not contiguous)
- to update the cells range of the chart
Normally, the chart should be automatically updated after that, but I have nothing.
Am I clear enough ? |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
Posted: Wed Nov 26, 2003 11:10 pm Post subject: |
|
|
OK, I see now, but have no solution
The chart is updated when data in the rang of cells is updated. But when the range of cell change ?
I think you have to read the chapiter 10 (on charts) of the developperGuide and particulary
10.3.2 Data access.
The problem of developperGuide is that it show us example in Java. I have some difficulties to read Java. To access to the chart in OOoBasic is not hard. I show you sothing (far for your subject) but only as an example.
| Code: |
Sub RegressionLineON()
Dim chartxy,diagram
chartxy=Thiscomponent.sheets(0).charts(0).embeddedobject
diagram = chartxy.getdiagram
diagram.RegressionCurves=com.sun.star.chart.ChartRegressionCurveType.LINEAR
'diagram.RegressionCurves=1 do the same as the previous line
End Sub
|
When you execute this macro a Regression line appears in your chart (only if it's a xychart).
This code only works when you have already a chart in your sheet. If you want to erase the line :
| Code: |
Sub RegressionLineOFF()
Dim chartxy,diagram
chartxy=Thiscomponent.sheets(0).charts(0).embeddedobject
diagram = chartxy.getdiagram
diagram.RegressionCurves=0
End Sub
|
This code acceed only a property of a chart but shows you how you can do that. _________________ Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
|