Created attachment 174646 [details] calc file with macro code - chart name is empty even it is declared LILO starbase macro give name to chart proved by xraytool but manually the chart name is empty string To reproduce: - Run the macro code in the attachment .ods file. - Check Chart Name property - an empty string - Try manually to name the chart with the name defined in macro code - The"OK" button is grayed out. - Try to set any other name. You can. - LILO starbase macro code (included in a cell in the attachment) Sub LoadingLibraries BasicLibraries.LoadLibrary("XrayTool") End Sub Sub CreateCalcWithSimpleChart ' Definitions of variables Dim oSheet 'Sheet containing the chart Dim oRect 'How big is the chart Dim oCharts 'Charts in the sheet Dim oChart 'Created chart Dim oAddress 'Address of data to plot Dim sName$ 'Chart name Dim oChartDoc 'Embedded chart object Dim oTitle 'Chart title object Dim oDiagram 'Inserted diagram (data). Dim sDataRng 'Where is the data Dim oCalcDoc ' it is needed to define Point and Size in order to ' change Position and Size of Chart Objects Dim Pos_Chart As New com.sun.star.awt.Point Dim Pos_Title As New com.sun.star.awt.Point Dim Pos_SubTitle As New com.sun.star.awt.Point Dim Pos_xTitle As New com.sun.star.awt.Point Dim Pos_yTitle As New com.sun.star.awt.Point Dim Pos_Legend As New com.sun.star.awt.Point Dim Size_Chart As New com.sun.star.awt.Size Dim Size_Title As New com.sun.star.awt.Size Dim Size_SubTitle As New com.sun.star.awt.Size Dim Size_xTitle As New com.sun.star.awt.Size Dim Size_yTitle As New com.sun.star.awt.Size Dim Size_Legend As New com.sun.star.awt.Size 'Dont Forget to Define "Name of Sheet oSheets = ThisComponent.getSheets() oSheet = oSheets.getbyName( "Graph_stat" ) Chart_XPos = 0 Chart_YPos = 17000 Chart_Width = 16000 Chart_Height = 10000 Chart_New_XPos = Chart_New_XPos + Chart_Width + 900 'Creation of objects into variables oCalcDoc = CreateCalcForChart() sName = "stat1" sDataRng = "D17:F28" oAddress = oSheet.getCellRangeByName(sDataRng).getRangeAddress() oCharts = oSheet.getCharts() oRange = oSheet.getCellRangeByName( sDataRng ) 'The size of the whole chart If NOT oCharts.hasByName(sName) Then oRect = createObject("com.sun.star.awt.Rectangle") oRect.X = Chart_New_XPos oRect.Y = Chart_YPos oRect.width = Chart_Width oRect.Height= Chart_Height oCharts.addNewByName(sName, oRect, Array(oAddress), True, True) End If ' Getting the Chart for manipulations oChart = oCharts.getByName(sName) oChart.setRanges(Array(oAddress)) oChartDoc = oChart.getEmbeddedObject() oDiagram = oChartDoc.createInstance("com.sun.star.chart.ChartDiagram") oChartDoc.setDiagram(oDiagram) oDiagram = oChartDoc.getDiagram() 'Inside the Chart, Setting Position and Size of the Diagram oChartDoc.RefreshAddInAllowed = True Pos_Chart.X = 300 Pos_Chart.Y = 1200 Size_Chart.width = Chart_Width - 800 Size_Chart.height = Chart_Height - 1500 oDiagram.setPosition( Pos_Chart ) oDiagram.setSize( Size_Chart ) end sub
Same as here maybe? id=125252