如何在Applescript中解决Microsoft Word时使用“考虑案例”

时间:2012-02-11 15:25:33

标签: ms-word applescript

以下Applescript代码无法编译;编译器突出显示“case”并说:“语法错误:预期的应用程序常量或考虑但找到的属性”。我猜casetell application "Microsoft Word"的上下文中具有特殊含义。我怎样才能很好地解决这个问题?

tell application "Microsoft Word"
    set c to content of character 1 of selection as string
    considering case
        if (c is "a") then
            set content of text object of selection to "A"
        end if
    end considering
end tell

2 个答案:

答案 0 :(得分:1)

fireshadow52是对的......

considering case
tell application "Microsoft Word"
    set c to content of character 1 of selection as string
    if (c is "a") then
        set content of text object of selection to "A"
    end if
end tell
end considering

答案 1 :(得分:1)

我要做的是尝试将considering块移到外面,以便它包含其他所有内容。

似乎case是Microsoft Word的保留字,因此在tell块内部使用该字时,只会混淆编译器,因此会出现语法错误。