Can anyone help with how to change the actual width of an embedded chart in StarOffice basic?
I'm using StarOffice 8 PU10 on Windows Vista Ultimate.
Code I have tried is below:
Code: Select all
Sub Main
Dim oDoc As Object
Dim Charts As Object
Dim Chart as Object
Dim Rect As New com.sun.star.awt.Rectangle
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
oDoc = ThisComponent
Charts = oDoc.getSheets().getByName("Sheet1").Charts
Rect.X = 12000
Rect.Y = 2000
Rect.Width = 10000
Rect.Height = 7000
RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = 0
RangeAddress(0).StartRow = 0
RangeAddress(0).EndColumn = 4
RangeAddress(0).EndRow = 2
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
ChangeChart
'ChangeWidth
End Sub
Sub ChangeChart()
'//Aim of code is to change the actual width of the chart
Dim oDoc As Object
Dim Charts As Object
Dim Chart as Object
Dim Cht as Object
Dim Rect As New com.sun.star.awt.Rectangle
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
oDoc = ThisComponent
Charts = oDoc.getSheets().getByName("Sheet1").Charts
RangeAddress(0).Sheet = oDoc.getSheets().getByName("Sheet1").RangeAddress.Sheet '// passes sheet index to celladdress object
RangeAddress(0).StartColumn = 0
RangeAddress(0).StartRow = 0
RangeAddress(0).EndColumn = 4
RangeAddress(0).EndRow = 4
Chart = Charts.getByName("MyChart")'.embeddedObject
Cht = Charts.getByName("MyChart").embeddedObject
Chart.setRanges(RangeAddress())
'Cht.Area.Size.Width = 40000 ' didn't fail but didn't change
'Cht.Area.Width = 40000 'failed
'Chart.Size.Width = 40000 ' failed
'Chart.Area.Size.Width = 40000 ' property or method not found
'Chart.Area.Width = 40000 ' property or method not found
'Cht.Area.setPropertyValue.("Width",40000)'variable expected
'Cht.setPropertyValue("Area.Size.Width",40000) 'fail
'Cht.Area.Size.setPropertyValue("Width",40000) 'fail
'Chart.Area.Size.setPropertyValue("Width",40000) 'fail
'Chart.Area.setPropertyValue.("Width",40000)'variable expected
Rect.X = 12000
Rect.Y = 2000
Rect.Width = 40000
Rect.Height = 7000
'Cht.setPropertyValue("Rectangle",40000)'fail
'Chart.setPropertyValue("Rectangle",40000)'fail
'Rect = Chart.Rectangle
'Chart.Rect.X = 12000'fail
'Chart.Rect.Y = 2000'fail
'Chart.Rect.Width = 40000'fail
'Chart.Rect.Height = 7000'fail
'Rect.X = 12000'fail
'Rect.Y = 2000'fail
'Rect.Width = 40000'fail
'Rect.Height = 7000'fail
End Sub
Area.Size.Width
I've hunted on http://api.openoffice.org/docs; the Developers manual; this forum; and http://wiki.services.openoffice.org/wiki/Documentation
but nothing clearly shows how to set this property.
I think setPropertyValue() should work or in the Developers manual, just referencing the property directly as in:
Code: Select all
Chart.Diagram.Deep = true
Any pointers or help very welcome!
I've attached a sheet example with code.
You would need to run Main to create the chart, then I have tried to modify using sub ChangeChart
Thanks
Mark