Search This Blog

Tuesday, September 21, 2010

Create a line chart in excel

Set Excel = CreateObject("Excel.Application")
Set Book = Excel.Workbooks.Open("E:\Performance.xls")
Set Sheet = Book.Worksheets(1)

Set Range = Sheet.UsedRange
Range.Select ' Selects the area in the excel sheet with the data

Set Charts= Excel.Charts
Charts.Add

Set objCharts = Charts(1)
objCharts.Activate

objCharts.ChartType = 65 ' This will select a line chart

objCharts.SeriesCollection(1).Border.Weight = -4138 'Used to increase the width of the line in the graph
objCharts.SeriesCollection(2).Border.Weight = -4138
objCharts.SeriesCollection(3).Border.Weight = -4138

Book.Save
Excel.Quit

For more details and other types of charts. Please refer the website:
http://technet.microsoft.com/en-us/library/ee692900.aspx

No comments:

Post a Comment