Hi Tibor, hope you are well.
Have been overtaken by events, not been 18 months working on this!
I have just re-visited it and have, with the help of another post (61596), Y axis max and min working OK with a couple of Push Buttons . I am trying to tidy it up with a scroll bar which puts the required Max and Min for the axis into cells F12 and F13 but still having a problem getting the contents of the cells into the Axis. The Macro so far…
Sub Scrollbar2click
Dim oSheet As Variant
Dim oCharts As Variant
Dim oChart As Variant
Dim oEmbeddedObject As Variant
Dim oDiagram As Variant
Dim oAxis As Variant
Dim oCellF12 as Variant
oSheet = ThisComponent.getCurrentController().getActiveSheet()
oCharts = oSheet.getCharts()
If oCharts.getCount() < 1 Then Exit Sub
oChart = oCharts.getByIndex(1) ’ Get First Chart or Enumerate all
’ of them with For i = 0 To oCharts.getCount()-1
oEmbeddedObject = oChart.getEmbeddedObject() ’ Get Object in selected frame
oDiagram = oEmbeddedObject.getDiagram() ’ Get diagram from it
Rem Now change values of any property - in this case XAxis and YAxis:
'oAxis = oDiagram.getXAxis()
’ oAxis.AutoMin = False
’ oAxis.AutoMax = False
’ oAxis.Min = oAxis.Min / 2
’ oAxis.Max = oAxis.Max * 1.5
oAxis = oDiagram.getYAxis()
oAxis.AutoMin = False
oAxis.AutoMax = False
oCellF12 = oSheet.GetCellRangeByName(“F12”)
oAxis.Min = oCellF12
End Sub
Which runs to the last line where it errors with “Incorrect Property Value”.
I guess I have not defined oCellF12 correctly, any ideas?
Regards
Uploaded .ods Apologies, it is a bit of a mess.
ScalingAxes3.ods (34.8 KB)