VBS: Adding trendline to chart

I have a vbscript which is generating the excel file, data and charts
When adding a trendline to a normal line chart (Excel 2007), it adds a tick for "Set Intercept" with a default value of 0.0, how do prevent this from being active? (code attached)
Set oExcel = createobject("Excel.application")
oExcel.Workbooks.open("c:\temp\test.xlsx")
oExcel.visible = true
oExcel.charts.add
oExcel.ActiveChart.Name = oTitle
oExcel.ActiveChart.ChartType = 4
oExcel.ActiveChart.SetSourceData rng, 1

oExcel.ActiveChart.SeriesCollection(1).Select
oExcel.ActiveChart.SeriesCollection(1).Trendlines.Add -4132, , 0, False,False, False

Open in new window

datacomsmtAsked:
Who is Participating?
 
jostranderConnect With a Mentor Commented:
on line 10, you have:
oExcel.ActiveChart.SeriesCollection(1).Trendlines.Add -4132, , 0, False,False, False

The last "False" is setting the trendline intercept to value of 0.  If you remove it
oExcel.ActiveChart.SeriesCollection(1).Trendlines.Add -4132, , 0, False,False
or
oExcel.ActiveChart.SeriesCollection(1).Trendlines.Add -4132, , 0, False,False,,False,False,"My Trendline"

Then it should be unchecked.

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.trendlines.add(office.11).aspx
0
 
datacomsmtAuthor Commented:
That solved it thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.