0



このメソッド  myFile.execute()  を使用して、InDesign ドキュメントをプログラムで開いています (この場合、スタイルが適用された空のドキュメントです)。


ドキュメントが開かれることもあれば、開かれないこともあります...スクリプトが完了する前にファイルを開く時間がないようです。


これは、テスト時に  探しているファイル名が表示され、適用時にスクリプトがalert(template.name)  エラースロー  しないFile(template).execute()ために発生しました  (変数  template  自体は既に  File  オブジェクトですが、単に  template.execute()  動作していません)。


関連するコードは次のとおりです。

function openStylesTemplate()
{
    var templateFolder = getScriptFolder(); // with the function below
    var fileArray = templateFolder.getFiles("*.indd"); // an array of all InDesign documents in this script's same folder

    try
    {
        var template = fileArray[0]; // the ONLY InDesign document in the folder
        File(template).execute(); // open the InDesign template document
    }
    catch(e)
    {
        alert("Error: " + e.message + "\n\n" +
                 "Make sure the InDesign styles document is in the same folder as this script,\n" +
                  "and that it is the ONLY InDesign document in this folder, and try again.\n\n" +
                 "This script is in this folder: " + templateFolder + ".");

        exit();
     }
} // end of function openStylesTemplate


では、スクリプトがドキュメントをロードするのに十分な時間がないのではないでしょうか? もしそうなら、この関数が呼び出される前にタイマーを作成する必要がありますか? または、InDesign ドキュメントをプログラムで開くためのより良い方法はありますか?

4

1 に答える 1

1

indesign ドキュメントをFile.execute()開くことは、ファイル自体を参照せずに単に OS の観点からファイルを開くこととは関係ありません。を呼び出してファイルを開きますapp.open ( file );

于 2012-07-20T09:13:54.787 に答える