(Excel.Series)SeriesCollection(1) : Cast exception
-
Tuesday, December 11, 2012 3:03 PM
Hallo there,
why the following line in C#
Excel.Series mySeries = (Excel.Series)myChart.SeriesCollection(1);
throws the following exception
Exception Type: System.InvalidCastException
What is the correct call in C# to get the series of a chart ?
If I try this way:
Excel.Series mySeries = (Excel.Series)myChart.SeriesCollection.Item(1);
I get the following compile error :
error CS0119: 'Microsoft.Office.Interop.PowerPoint.Chart.SeriesCollection(object)'
is a 'method', which is not valid in the given context
Best,
- Moved by Cindy Meister MVPMVP Tuesday, December 11, 2012 3:27 PM Excel-specific (From:Visual Studio Tools for Office)
- Edited by HeinrichMS Tuesday, December 11, 2012 3:31 PM adding text
All Replies
-
Wednesday, December 12, 2012 11:20 AMModerator
Hi HeinrichMS,
Thank you for posting in the MSDN Forum.
What is the correct call in C# to get the series of a chart
The first expression is correct, but you cannot cast PowerPoint.Series value to Excel.Series.
Hope it helps.
Best regards,
Quist Zhang [MSFT]
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked As Answer by HeinrichMS Wednesday, December 12, 2012 10:33 PM

