Format Chart using excel object model.

A

Abdul Qadir Khan

Hi,

I want to create bar and line charts using excel object model from VB. I
able to create charts but problem is formating. I want two things very
urgent:

1) How to change the color of bars in bar chart and change the color of line
in line chart.
2) How to show data labels.

Waiting for your reply.

Thanks
AQ
 
A

Andy Pope

Hi AQ,

Here is some code to give you an idea of the code needed.
These examples where modified from code produced using the macro
recorder in Excel.

Sub RedBars()
ActiveChart.SeriesCollection(1).Interior.Color = RGB(255, 0, 0)
End Sub
Sub RedLine()
ActiveChart.SeriesCollection(1).Border.Color = RGB(255, 0, 0)
End Sub
Sub ShowDataLabels()
ActiveChart.SeriesCollection(1).ApplyDataLabels
Type:=xlDataLabelsShowLabel, _
AutoText:=True, LegendKey:=False
End Sub

Chers
Andy
 
A

Abdul Qadir Khan

Thanks it works. You also give me very good direction of using macro for
this. Now I record macro for anything and see the code to implement in my
own program.

Thanks again.
Abdul Qadir Khan.
 

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

Top