AppleScript:设置 Microsoft Excel 单元格的背景颜色 [英] AppleScript: set Microsoft Excel cell's background color

查看:51
本文介绍了AppleScript:设置 Microsoft Excel 单元格的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 AppleScript,如何将单元格范围从 A3 到 E3"的背景颜色更改为浅灰色?

Using AppleScript, how can I change the background color of "cells ranging from A3 to E3" to light grey?

我仍然希望字体为黑色.

I still want the font to be in black.

推荐答案

此答案的两个警告:您没有指定 Excel 的版本,以下内容在 v2004 中进行了测试.

Two caveats with this answer: You didn't specify which version of Excel, and the following was tested in 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

根据字典,color index 是颜色被指定为当前调色板的索引值".换句话说,您安装中浅灰色的颜色索引可能在其他地方有所不同.

Per the dictionary, color index is "the color is specified as an index value into the current color palette". In other words, the color index that is light gray in your install maybe different elsewhere.

这篇关于AppleScript:设置 Microsoft Excel 单元格的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆