how to change chart colors

  • Thread starter Thread starter dlw
  • Start date Start date
D

dlw

Can anyone help me with a request we have from a client.

We have a report with over 50 bar charts and we just got
asked by our client to change the colors used. Have been
trying to write a macro to open each chart and change the
color used for the 5 series. Macro was not working.
Someone told me can't write a macro to do this in
PowerPoint.

Anyone have an idea how to do this without openning each
chart manually and changing the colors?

Thanks
dlw
 
Can anyone help me with a request we have from a client.

We have a report with over 50 bar charts and we just got
asked by our client to change the colors used. Have been
trying to write a macro to open each chart and change the
color used for the 5 series. Macro was not working.
Someone told me can't write a macro to do this in
PowerPoint.

It can be done in PowerPoint. Google "MSGraph automation" or "automate
MSGraph" for some ideas, particularly about how to get a reference to and start
automating Graph.

The MSGraph help file has a lot of detailed info about the object model. You
can't record macros while you make changes to MSGraph charts, but you *can* do
it while you change similar charts in Excel. The object models are very
similar; that'll give you a nice head start.
 
dlw said:
Can anyone help me with a request we have from a client.

We have a report with over 50 bar charts and we just got
asked by our client to change the colors used. Have been
trying to write a macro to open each chart and change the
color used for the 5 series. Macro was not working.
Someone told me can't write a macro to do this in
PowerPoint.

Anyone have an idea how to do this without openning each
chart manually and changing the colors?

Thanks
dlw

I am not versed in VB (I work with C++) so my attempts at this were
tough (and the following code is quite ugly and can be improved by
others). I had a cross-tab graph with a bunch of series. Basically I
wanted a gradual change in color from one end of the spectrum to the
other. To do this, I came up with the following (using MS-Access
2002). The Chart / Graph is in a Form.

Function a()
Set bbb = Application.Forms("Form1")("OLEUnbound3")
Div = Fix(255 / bbb.SeriesCollection.Count)
For a = 1 To bbb.SeriesCollection.Count
bbb.SeriesCollection(a).Interior.Color = RGB(a * Div, 255 - (a *
Div), 0)
bbb.SeriesCollection(a).Border.Color = RGB(a * Div, 255 - (a *
Div), 0)
bbb.SeriesCollection(a).Border.LineStyle = xlNone
bbb.SeriesCollection(a).MarkerSize = 2
Next a

End Function
 
Only 8 of the colors in MS Graph can be changed. The others cannot be
changed. To really do what you want you'd want to create the charts in
Excel where all the 56 colors can be changed.
There's sample VBA code at
http://www.rdpslides.com/pptfaq/FAQ00249.htm
Then when you want to change the color of a shape/series etc. use the
colorindex property rather than the rgb value.

Brian Reilly, PowerPoint MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top