3

AppleScript を使用して、数値ファイル (テンプレートに基づいて毎日新しいシートが必要) でシートを複製しようとしています。私はAppleScriptに本当に慣れていませんが、実行したPythonスクリプトから取得した結果をいくつかのセルに入力するためにすでに使用していますが、このビットはまだ手動です... =/

tell application "Numbers"
tell document 1
    set thisSh to make new sheet with properties {name:"May14"}
    duplicate sheet "Template" to sheet "May14"
end tell
end tell

上記のコードはエラーを返します:error "Numbers got an error: Sheets can not be copied." number -1717したがって、私の質問: 数字シートを複製する方法はありますか?

現在 iWork '14 を数字 3.2 で実行しています

ありがとう!

PS私もduplicate every table of sheet "Template" to sheet "May14"同様のエラーで試しました:Tables can not be copied.

4

1 に答える 1

2

2 つのオプションがあります。プログラムで新しいシートにテーブルを作成するか、最初のシートからテーブルを選択してコピーし、新しいシートにコピーすることができます。2 番目のオプションのコードを次に示します。テンプレート シートのスクリーン グラブを見たことがないので、調整する必要があるかもしれませんが、これで必要なものがすべて得られるはずです。問題が発生した場合は、テンプレート シートのスクリーンショットと説明を投稿してください。 シート内の非常に多くのテーブルを考慮して更新されました。アクティブなシートを変更する方法を示すために再度更新されました。

tell application "Numbers"
    activate
    tell document 1
        set tempSheet to first sheet whose name is "My Template"
        set active sheet to tempSheet
        tell application "System Events"
            -- deselect all
            keystroke "a" using {command down, shift down}
            delay 0.1
            -- select all containers (tables, text items, etc.)
            keystroke "a" using {command down}
            delay 0.1
            -- copy the containers
            keystroke "c" using {command down}
        end tell
        delay 0.1
        set dateString to (month of (current date)) & (day of (current date)) as string
        set thisSheet to make new sheet with properties {name:dateString}
        tell thisSheet
            delete every table
            tell application "System Events"
                keystroke "v" using {command down}
            end tell
        end tell
    end tell
end tell
于 2014-05-22T18:26:48.683 に答える