使用AppleScript在Microsoft Word中设置表格边框

时间:2012-10-07 17:18:46

标签: ms-word applescript

当我尝试设置表格边框的线条粗细时,结果会将线条类型更改为不需要的线条。为什么线宽参数会影响线型参数?请参阅下面的示例并亲自尝试。我正在使用MS Office 2011 Word v14.2.3。

tell application "Microsoft Word"
    set line style of (get border selection which border border bottom) to line width225 point
    get line width of (get border selection which border border bottom)--test:results in line width150. Why? I just set it to line width225!

    --width25 = fine dots
    --width225 = cornered sine wave
    --width50 = dashed line
    --width75 = dash + 3 dots + dash
    --width100 = 3 lines
    --width150 = 2 lines
    --width300 = single
    --width450 = does not work
    --width600 = does not work
end tell

如果我在具有我想要的设置的桌面上运行它,以便查看它们是什么:

tell application "Microsoft Word"
    get properties of (get border selection which border border bottom)
end tell

我明白了:

{class:border, visible:true, color index:no highlight, inside:false, line style:line style single, line width:line width225 point, art style:missing value, art width:missing value, color:{0, 0, 0}, color theme index:no theme color}

哪个是对的。我应该能够复制这些参数以使我的脚本工作,但是当我尝试设置线宽(边框粗细)时会发生一些事情。

1 个答案:

答案 0 :(得分:1)

如果您想更改线条粗细,请使用line width代替line style,否则正常情况下它不会达到预期效果。

set line width of (get border selection which border border bottom) to line width225 point

如果您想更改line style,您应该使用此列表中的值:( 线条样式无,线条样式单一,线条样式点,线条样式划线小差距等等......)