将图表另存为.jpeg文件

多年来我一直在使用Excel图表来制作用于教授物理的电脑animation电影。 但是,在从VBA转换到AppleScript时,我很难将图表保存为.jpeg文件。 我已经尝试过下面的脚本:

tell application "Microsoft Excel" set filebasename to get value of cell "MovieName" activate object chart object filebasename of sheet 1 set testfile to "test.jpg" save as picture active chart picture type save as JPG file file name testfile end tell 

但AppleScript编辑器告诉我活动图表不理解保存为图片的指令。 我的解决方法是使用脚本:

 tell application "Microsoft Excel" set filebasename to get value of cell "MovieName" activate object chart object filebasename of sheet 1 copy picture active chart appearance screen format picture end tell 

然后通过剪贴板到GraphicConverter得到一个.jpeg文件。

我在做什么这是愚蠢的?

 tell application "Microsoft Excel" set theValue to get value of cell "A1" set myNewChartObject to make new chart object at sheet 1 with data theValue with properties {width:100.0, height:100.0} save as picture myNewChartObject picture type save as JPG file file name (((path to desktop folder) as text) & "myChart.jpg") as text end tell 

加盐调味。 这里有一个小的解剖…

make命令用于创build几乎所有types的对象,并为您返回创build的对象。 activate没有,这可能是为什么save as picture失败,因为你没有一个对象来实际保存。 我会冒险猜测active chart是不够的命令去,因为目前活动的对象可以改变,而你没有意识到。 抓住这个对象,将它应用到一个variables,然后传递它,通常是一个好主意,因为那样你就知道你需要使用什么了。