How to programmatically create Excel charts

Add-in Express™ Support Service
That's what is more important than anything else

How to programmatically create Excel charts
Excel Charts via COM automation 
Sebastian Streit




Posts: 3
Joined: 2011-01-03
Do you have any help page or source code how to automate Excel to make charts?

Thanks for your help!
Sebastian
Posted 15 Jun, 2011 01:40:15 Top
Andrei Smolin


Add-in Express team


Posts: 18847
Joined: 2006-05-11
Hi Sebastian,

I suggest that you record a macro while creating a chart. Then you convert the macro to the programming language of your choice.


Andrei Smolin
Add-in Express Team Leader
Posted 15 Jun, 2011 02:46:34 Top
Sebastian Streit




Posts: 3
Joined: 2011-01-03
Ups - me and VBA Macros :-(

Do you by chance have any examples what to expect there? Or literature where to start with charting in Excel?
Posted 15 Jun, 2011 02:51:26 Top
Andrei Smolin


Add-in Express team


Posts: 18847
Joined: 2006-05-11
It isn't that difficult. In the Developer tab, you click Record Macro and specify that it is written to your workbook. Then you insert a chart and stop recording the macro. Finally, you press Alt+F11, find the newly created module (Module1 if it is the first one) and see the macro. It may resemble the following one:

Sub Macro1()
'
' Macro1 Macro
'

'
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlLineMarkers
    ActiveChart.SetSourceData Source:=Range("Sheet1!$B$4:$C$9")
End Sub



Andrei Smolin
Add-in Express Team Leader
Posted 15 Jun, 2011 03:25:02 Top
Sebastian Streit




Posts: 3
Joined: 2011-01-03
Thank you very much Andrei! Greetings to Belarus from Switzerland :-)
Posted 15 Jun, 2011 03:34:14 Top