Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default VBA chart formatting

How can I format individual serieslines within a chart group?

Why does this not change the LineStyles?

Set ChtSht = Worksheets("Sheet1")
Dim ChtObj As ChartObject


For Each ChtObj In ChtSht.ChartObjects

Debug.Print "Chart Object #: " & ChtObj.Index

ChtObj.Activate
Debug.Print "Number of Chart Groups is: " &
ActiveChart.ChartGroups.Count
'Debug.Print ChtObj.ChartGroups.Count 'object doesn't support property
or method

Debug.Print "Number of series is: " & ActiveChart.SeriesCollection.Count

ActiveChart.ChartGroups(1).HasSeriesLines = True

With ActiveChart.ChartGroups(1).SeriesLines.Border
.LineStyle = xlDashDotDot 'unable to set LineStyle property of Border
.Weight = xlMedium
.ColorIndex = 3
End With

Next ChtObj

The immediate widow:

Chart Object #: 1
Number of Chart Groups is: 1
Number of series is: 4



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default VBA chart formatting

There's not much that's right with your code to work with or guess what you
are doing overall. OK a guess - you want to format the first series, which
is a line type, in each chart to have a red border

Sub test()
Dim i As Long
Dim cht As Chart
Dim sr As Series

For i = 1 To ActiveSheet.ChartObjects.Count
Set cht = ActiveSheet.ChartObjects(i).Chart
Set sr = cht.SeriesCollection(1)
' or if there's a particular need to work with chartgroups(1)
'Set sr = cht.ChartGroups(1).SeriesCollection(1)

sr.Border.ColorIndex = 3

' this will error if the series does not have markers
'sr.MarkerBackgroundColorIndex = 3
'sr.MarkerForegroundColorIndex = 3

Next

End Sub

Regards,
Peter T


"Arne" wrote in message
...
How can I format individual serieslines within a chart group?

Why does this not change the LineStyles?

Set ChtSht = Worksheets("Sheet1")
Dim ChtObj As ChartObject


For Each ChtObj In ChtSht.ChartObjects

Debug.Print "Chart Object #: " & ChtObj.Index

ChtObj.Activate
Debug.Print "Number of Chart Groups is: " &
ActiveChart.ChartGroups.Count
'Debug.Print ChtObj.ChartGroups.Count 'object doesn't support
property
or method

Debug.Print "Number of series is: " &
ActiveChart.SeriesCollection.Count

ActiveChart.ChartGroups(1).HasSeriesLines = True

With ActiveChart.ChartGroups(1).SeriesLines.Border
.LineStyle = xlDashDotDot 'unable to set LineStyle property of
Border
.Weight = xlMedium
.ColorIndex = 3
End With

Next ChtObj

The immediate widow:

Chart Object #: 1
Number of Chart Groups is: 1
Number of series is: 4





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default VBA chart formatting

Peter,

Using the Border property of SeriesCollection(i)

The object browser shows Border is a property of SeriesLines which is a
property of ChartGroup. the help system says:

With Charts("Chart1").ChartGroups(1)
.HasSeriesLines = True
With .SeriesLines.Border
.LineStyle = xlThin
.Weight = xlMedium
.ColorIndex = 3
End With
End With

I was able to change the series line formatting with
SeriesCollection(i).Border

Arne

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy chart formatting and chart templates in Excel 2007 Astelix Charts and Charting in Excel 4 March 4th 10 04:10 AM
Chart formatting Dave F[_3_] Excel Discussion (Misc queries) 0 March 6th 08 06:42 PM
Pivot Chart Refresh cancels all chart formatting Nico[_2_] Charts and Charting in Excel 2 September 9th 07 05:22 AM
chart formatting BorisS Excel Programming 2 June 20th 07 12:57 PM
Pivot Table border formatting and pivot chart formatting [email protected] Excel Discussion (Misc queries) 0 July 22nd 05 02:22 PM


All times are GMT +1. The time now is 02:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"