Hy everybody,
I’ve tried to create a chart with applescript with the following :
set object_graph to make new chart object at active sheet with properties {top:60, left position:5, height:350, width:450}
And the result is :
Unable to create class chart object.
Does someone has an idea about this mystic problem ???
Franck
One needs to tell Excel to do that. And then assign series, data ranges, chart type etc.
tell application "Microsoft Excel"
set object_graph to make new chart object at active sheet with properties {top:60, left position:5, height:350, width:450}
end tell
Thanks for your answer, but unfortunately i have inserted the tell block and nothing runs.
Some ideas ???
Franck
I have only little experience with Excel, but I think a sheet belongs to a document:
tell application "Microsoft Excel" to tell document 1 to set object_graph to make new chart object at active sheet with properties {top:60, left position:5, height:350, width:450}
Hope it works,
ief2
PS: Tested now, and it works on my machine
My script made a blank white box (Chart Object) on the Active Sheet when I ran it.
What version of Excel?
In Excel 10.1.5 I found it easier to create the chart by hand the first time then use ExtendSeries to update it as new data arrives.
(Where myRange is in the format “Range A1,B1”)
ExtendSeries of every Series of ActiveChart RowOrCol xlColumns Source myRange
I’m going to miss Excel 10’s recordability when we finally upgrade. Excel is very convoluted to use without it. 
Just ran into this commented-out code in my own Excel data charting project: didn’t work in Excel 10 (ChartWizard wasn’t fully implemented), but maybe work for you?
--
-- Charting and ChartWizard syntax provided with the help of
--"Jacques" of MacScripter.net, 4/17/06
--
--make chart
try
Select Chart "Charting"
on error
set newChart to Create New Chart After ActiveSheet of ActiveWorkbook
end try
Select Sheet "Data Capture"
set myRange to Range ("A2:A" & gEndRow & ",D2:D" & gEndRow) of ActiveSheet --put in your own range numbers or calculations
Select Chart "Charting"
ChartWizard ActiveChart Source myRange Gallery xlLine Format 4 PlotBy xlColumns Title "Server Free Space Over Time" CategoryAxisTitle "DATE" ValueAxisTitle "FREE SPACE" without HasLegend
--rename chart sheet
try
Select Sheet "Chart1"
set Name of ActiveChart to "Charting"
end try
Hy guys,
Two things work :
the first one is the solution of ief2 :
tell application "Microsoft Excel" to tell document 1 to set object_graph to make new chart object at active sheet with properties {top:60, left position:5, height:350, width:450}
and the second thing is to repeat tell application “Microsoft excel” a second time … let me explain to you what i did :
I had
tell application "Microsoft Excel"
my code (many lines)
creation of chart
end tell
then i did
tell application "Microsoft Excel"
my code (many lines)
end tell
tell application "Microsoft Excel"
creation of chart
end tell
and this works
Everything happens like if the tell block was lost …
Thanks to everybody. My code runs but i don’t know why 