如何使用苹果脚本在excel中设置常量序列值

如何使用苹果脚本在excel中设置常量序列值。

tell worksheet 1 of active workbook set obj to make new chart object at end with properties{ left position:120,top:50,width: 120,height:150} set ochart to chart of obj tell ochart make new series at end with properties {series values:"={1}"} end tell end tell This script through error(Microsoft Excel got an error:Can't make class series) Please replay 

我不确定我的语法是否错误,或者这是一个错误。

系列

你会希望能够创build一个常数的新系列,使用:

 set newSeries to make new series at end with properties {name:"tempSeriesName", series values:{50}} 

但是,我只能使用一个范围来创build系列:

 set newSeries to make new series at end with properties {name:"tempSeriesName", series values:"A2"} 

但是,一旦创build系列,您可以更新值:

 set series values to {50} 

我的解决方法是find列A中的第一个空白单元格,并填充一个值。 然后,我使用这个单元格来创build范围,用常量更新范围,然后将临时单元格还原为空白。

 tell application "Microsoft Excel" tell worksheet "Sheet1" of active workbook -- Find the first empty cell and populate it with 1 set counter to 0 repeat set counter to counter + 1 set myRange to ("A" & counter as text) if value of range myRange = "" then set value of range myRange to "1" exit repeat end if end repeat set obj to make new chart object at end with properties {name:"chart1", left position:20, top:88, width:33, height:90} set ochart to chart of obj tell ochart set chart type to column clustered -- create the chart with the temporary value set newSeries to make new series at end with properties {name:"tempSeriesName", series values:myRange} -- update the chart with your constant value set series values of newSeries to {50} end tell set value of range myRange to "" end tell end tell 

图表