vba - Looping through seriescollection and format series fill color -


i'm trying work on code in powerpoint(ppt) loop through column charts in ppt , format each column bars in series collection specific colors. works when number of bars = number of lines wrote series fill color. eg. when have 15th line ".seriescollection(15).format.fill.forecolor.rgb = rgb(250, 10, 10)" charts have 10 columns, have error. when there 15 columns works.

but chances number of column random on ppt , ask if there's way =1 seriescollection.count if i=1, choose ".seriescollection(1) color, i=2, choose ".seriescollection(1) color , on...

my code below, great appreciate if point me how should modify codes , make works

thanks

for each slide in activepresentation.slides each shape in slide.shapes if shape.haschart = true if shape.chart.charttype = xlcolumnstacked  sh.chart      each ser in .seriescollection         .seriescollection(1).format.fill.forecolor.rgb = rgb(10, 10, 10)         .seriescollection(2).format.fill.forecolor.rgb = rgb(30, 10, 10)         .seriescollection(3).format.fill.forecolor.rgb = rgb(50, 10, 10)         .seriescollection(4).format.fill.forecolor.rgb = rgb(70, 10, 10)         .seriescollection(5).format.fill.forecolor.rgb = rgb(90, 10, 10)         .seriescollection(6).format.fill.forecolor.rgb = rgb(120, 10, 10)         .seriescollection(7).format.fill.forecolor.rgb = rgb(140, 10, 10)         .seriescollection(8).format.fill.forecolor.rgb = rgb(160, 10, 10)         .seriescollection(9).format.fill.forecolor.rgb = rgb(10, 180, 10)         .seriescollection(10).format.fill.forecolor.rgb = rgb(10, 200, 10)         .seriescollection(11).format.fill.forecolor.rgb = rgb(10, 230, 10)         .seriescollection(12).format.fill.forecolor.rgb = rgb(10, 10, 50)         .seriescollection(13).format.fill.forecolor.rgb = rgb(10, 10, 150)         .seriescollection(14).format.fill.forecolor.rgb = rgb(10, 10, 200)         .seriescollection(15).format.fill.forecolor.rgb = rgb(250, 10, 10)      next  end  end if end if next next 

do mean code below:

dim sercount long  sercount = sh.chart.seriescollection.count  select case sercount     case 1      case 2      ' etc...  end select 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -