使用 Applescript 更改 Excel 中某些单元格的背景颜色

Changing the background color of certain cells in Excel using Applescript

所以我想知道您是否可以使用 Applescript 更改 Microsoft Excel 中某些单元格的背景颜色。

我已经了解如何定位特定单元格,但 back color(包含在脚本字典中)、background color(不包含在脚本字典中)和 color 都没有结果除了 missing value 和错误之外的任何内容。到目前为止,这是我的代码:

tell application "Microsoft Excel" to set back color of cell "A1" of front sheet of front document to {255, 244, 233}

Ranges/cells 有一个 'interior',您可以使用 interior object 访问它。在字典中查找 'interior'。还有其他相关属性。您也可以类似地影响边框颜色。

所以……

set color of interior object of range "A1" to {255, 244, 233}

您还可以通过应用颜色索引来应用一些预设颜色,就像这样……

set color index of interior object of range "A1" to 6

有一种获取无数颜色索引号的方法,但我忘记了它是什么(除了反复试验)。但是,如果您通过单击调色板来分配颜色,则可以为该范围 get color index。实际上,excel 的 applescript 文档有一个带有数字的调色板 table。