I read a thread here about adding more than one series at an Excel chart that helped me a lot, but I also need to add 3 ranges of information to a same line (series) on a chart.
My objective is getting information from another Excel file, move it to the file with the charts and add the information (which is stored as normal text on the first sheet) to the charts.
I manage to create a series with two ranges, using this:
$xlChartType=[Microsoft.Office.Interop.Excel.XLChartType]
$XlLegendPosition=[Microsoft.Office.Interop.Excel.XlLegendPosition]
$chart=$WorksheetTool2.Shapes.AddChart().Chart
$chart.chartType=$xlChartType::xlLineMarkers
$chart.SeriesCollection().NewSeries.Invoke()
$chart.SeriesCollection(1).Values = $WorksheetTool1.Range("D10:D11","D20:D24")
$chart.SeriesCollection(1).Name = "=""First""
but I need to add a third range, if I add a third range the error I'm getting is:
Exception getting "Range": "Cannot find an overload for "Range" and the argument count: "3"." At C:\Users\graciela_robert\Desktop\PerfTool\script.ps1:57 char:1 + $chart.SeriesCollection(1).Values = $WorksheetTool1.Range("D10:D11","D20:D24","D ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], GetValueInvocationException + FullyQualifiedErrorId : CatchFromBaseParameterizedPropertyAdapterGetValue
Does anyone knows how to add a third range into this chart?
Also, I'm trying to move the chart legend to the bottom by using
$XlLegendPosition=[Microsoft.Office.Interop.Excel.XlLegendPosition]
$chart.Legend=$XlLegendPosition::xlLegendPositionBottom
But it doesn't work. I also tried just "#$chart.Legend=--4107" which I read here, but it also doesn't work. No errors, just nothing changes.
Sorry for the two questions! Thanks!