简体   繁体   English

AppleScript:设置 Microsoft Excel 单元格的背景颜色

[英]AppleScript: set Microsoft Excel cell's background color

Using AppleScript, how can I change the background color of "cells ranging from A3 to E3" to light grey?使用 AppleScript,如何将“单元格范围从 A3 到 E3”的背景颜色更改为浅灰色?

I still want the font to be in black.我仍然希望字体为黑色。

Two caveats with this answer: You didn't specify which version of Excel, and the following was tested in v2004.此答案有两个警告:您没有指定 Excel 的版本,以下内容在 v2004 中进行了测试。

tell application "Microsoft Excel"
    set theRange to range "A3:E3"
    set interiorObject to interior object of theRange
    set color index of interiorObject to 5 -- '5' is only a dummy value; change as needed.
end tell

Per the dictionary, color index is "the color is specified as an index value into the current color palette".根据字典, color index是“颜色被指定为当前调色板的索引值”。 In other words, the color index that is light gray in your install maybe different elsewhere.换句话说,您安装中浅灰色的颜色索引可能在其他地方有所不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM