VB.net 2008 running a Office 2010 Excel sheet. I am trying to create a chart with multiple series (graph lines). One set is a bar graph, the other a line graph.
I can do one or the other normally, but need them both on the same chart.
When I try to set the XValues; I get "A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll"
This gets the same error:
.SeriesCollection(1).XValues = "=FWpd!R3C1:R" & Rd & "C1"
Any ideas guys?
I can do one or the other normally, but need them both on the same chart.
Code:
Imports Excel = Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Interop
Rd = (ObjXLBook.Sheets("FWpd").UsedRange.Rows.Count - 1)
ObjXLApp.Charts.Add()
Dim chart = ObjXLBook.ActiveChart
'-- create chart for section
ObjXLApp.Workbooks(1).Sheets("FWpd").Activate()
With chart
.SeriesCollection(1).AxisGroup = 1
.SeriesCollection(1).ChartType = Excel.XlChartType.xlColumnClustered
.SeriesCollection(1).XValues = ObjXLApp.Workbooks(1).Sheets("FWpd").Range("A3:A" & Rd)
.SeriesCollection(1).Values = ObjXLApp.Workbooks(1).Sheets("FWpd").Range("B3:B" & Rd)
.SeriesCollection.NewSeries()
.SeriesCollection(2).AxisGroup = 2
.SeriesCollection(2).ChartType = Excel.XlChartType.xlLineMarkers
.SeriesCollection(2).XValues = ObjXLBook.Sheets("FWpd").Range("A3:A" & Rd)
.SeriesCollection(2).Values = ObjXLBook.Sheets("FWpd").Range("C3:C" & Rd)
end with
When I try to set the XValues; I get "A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll"
This gets the same error:
.SeriesCollection(1).XValues = "=FWpd!R3C1:R" & Rd & "C1"
Any ideas guys?