Rectangle 27 1

powershell cannot add more than one legend entry (series) to an excel chart?


$chart.SeriesCollection().NewSeries.Invoke()
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Sheet2").Range("B3:P3")
ActiveChart.SeriesCollection(1).Name = "=""First"""
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Values = "=Sheet2!$B$4:$P$4"
ActiveChart.SeriesCollection(2).Name = "=""Second"""
ActiveChart.SeriesCollection(2).XValues = "=Sheet2!$B$2:$P$2"

And that's it, I guess there's some difference from calling the VBA in the macro I made in Excel to begin this development:

Problem solved, had to call Invoke() on the newSeries - so:

To calling it in powershell, I have not found one good example on doing this adding of series dynamically to an Excel Chart on the WEB!

Note