Hi,
Can anyone please help me in figuring out what change needs to be done to the below code in order to show the chart (the chart I want is displayed only when I click the "Switch Row/Column" button on the toolbar, I want it to be displayed automatically without manually clicking the button - please see the attached file). Below is my code:
Any help is highly appreciated.
Regards,
Aads
Can anyone please help me in figuring out what change needs to be done to the below code in order to show the chart (the chart I want is displayed only when I click the "Switch Row/Column" button on the toolbar, I want it to be displayed automatically without manually clicking the button - please see the attached file). Below is my code:
Code:
Private Sub DisplayGraph()
Try
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
xlApp = New Excel.ApplicationClass
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
xlApp.Visible = True
'Adding Data..
xlWorkSheet.Cells(1, 1) = 2
xlWorkSheet.Cells(1, 2) = 1
xlWorkSheet.Cells(2, 1) = 3
xlWorkSheet.Cells(2, 2) = 2
xlWorkSheet.Cells(3, 1) = 2
xlWorkSheet.Cells(3, 2) = 5
xlWorkSheet.Cells(4, 1) = 4
xlWorkSheet.Cells(4, 2) = 7
xlWorkSheet.Cells(5, 1) = 8
xlWorkSheet.Cells(5, 2) = 2
xlWorkSheet.Cells(6, 1) = 5
xlWorkSheet.Cells(6, 2) = 3
Dim oChart As Excel._Chart
oChart = xlWorkBook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value)
oChart.ChartWizard(xlWorkSheet.Range("A1", "B6"), Excel.XlChartType.xlXYScatterLines, Missing.Value, _
Excel.XlRowCol.xlRows, _
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, _
Missing.Value, Missing.Value)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Regards,
Aads