|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Trendlines Object (Word)
Represents a collection of all the Trendline objects for the specified series.
Use the Trendlines method to return the Trendlines collection. The following example displays the number of trendlines for series one of the first chart in the active document.
With ActiveDocument.InlineShapes(1) If .HasChart Then MsgBox .Chart.SeriesCollection(1).Trendlines.Count End If End With
Use the Add method to create a new trendline and add it to the series. The following example adds a linear trendline to the first series for the first chart in the active document.
With ActiveDocument.InlineShapes(1) If .HasChart Then .Chart.SeriesCollection(1) _ .Trendlines.Add Type:=xlLinear, Name:="Linear Trend" End If End With
Use Trendlines(Index), where Index is the trendline index number, to return a single TrendLine object. The following example changes the trendline type for the first series of the first chart in the active document. If the series has no trendline, this example will fail.
The index number denotes the order in which the trendlines were added to the series. Trendlines(1) is the first trendline added to the series, and Trendlines(Trendlines.Count) is the last one added.