0

以下脚本在 AppleScript 编辑器中运行时以文本形式返回页面上对象的自选图形类型。但是,当从 PowerPoint 中的 applescript 菜单运行时,它会返回一个脚本常量。

我正在使用一个更复杂的版本来根据对象的自动形状类型将对象的属性发送到不同的应用程序......表格放在一个地方,占位符另一个,矩形等到第三个。我也在 PPT 中启动它以推出数据,并且不能真正从任何其他应用程序中提取它,因此 AppleScript 菜单将是我想要的位置。

谁能告诉我为什么同一个脚本会给出两个结果?

谢谢,亚历克斯

tell application "Microsoft PowerPoint"
    set currentSlideNumber to slide index of slide range of selection of document window 1
    set theSlide to slide currentSlideNumber of active presentation
end tell

getProperty(theSlide)

to getProperty(theSlide)
    tell application "Microsoft PowerPoint"
        repeat with thisShape in (get every shape of theSlide)
          set shapeType to shape type of thisShape
          set shapeContent to content of text range of text frame of thisShape
          display alert (shapeType as string)
     end repeat
end tell

结束 getProperty

4

1 回答 1

0

将常量(或标准 applescript 无法理解的应用程序属性)转换为文本是很棘手的。我的猜测是,当在 powerpoint 菜单中时,脚本可以更好地理解常量,因此您会看到这一点。

无论如何,我对 Finder 常量有同样的问题,并决定自己使用 if 语句处理转换为文本的问题。这是一个麻烦的解决方案,因为您必须考虑每个常数,但至少您知道它会正确发生。

这是一个例子。假设有一个形状常数“rect”代表矩形,“circ”代表圆形。

注意:您可能可以使用实际属性的名称而不是代码中的常量。

to getProperty(theSlide)
    tell application "Microsoft PowerPoint"
        repeat with thisShape in (get every shape of theSlide)
            set shapeType to shape type of thisShape
            if shapeType is <<rect>> then
                set shapeTypeText to "rectangle"
            else if shapeType is <<circ>> then
                set shapeTypeText to "circle"
            end if

            set shapeContent to content of text range of text frame of thisShape

            display alert (shapeTypeText)
        end repeat
    end tell
end getProperty
于 2013-09-11T14:43:41.453 回答