032.【ID】全ての表の1行目をヘッダーにする
書いたコード
var tableParents = myFindText('<0016>'); for (var i=0;i<tableParents.length;i++){ tableParents[i].tables.everyItem().rows.firstItem().rowType=RowTypes.HEADER_ROW; } function myFindText(str){ app.findTextPreferences=NothingEnum.NOTHING; app.findTextPreferences.findWhat=str; var result = app.findText(); return result; app.findTextPreferences=NothingEnum.NOTHING }
メモ
分かったこと
表の取得
ドキュメント上の全ての表(アンカー付きオブジェクト内の表や表内表も含む)にアクセスするためにかなり試行錯誤した。
- app.activeDocument.textFrames.everyItem().tables.everyItem()
アンカー付きオブジェクト内の表や表内表にアクセスできない。
- app.activeDocument.allPageItemsのtables.everyItem()
アンカー付きオブジェクトは含むが表内表にまでアクセスするのが難しい。
- app.findText()で<0016>を検索
表を子にもつ全てのcharacterオブジェクトを取得。
レイヤーのロック、表示/非表示、マスターにあるか等に注意する必要がある?
everyItem()
Documented as returning an Array of the elements within the collection.
Sounds to be equivalent to this.itemByRange(0,-1).
(Indiscripts :: On ‘everyItem()’ – Part 1)
everyItem()、データブラウザで見ると配列じゃなくてテキストフレームオブジェクトや表オブジェクトそのものになってた。
everyItem().move()のような書き方ができることを考えると、配列とはちょっと違う?
参考
- Indiscripts :: On ‘everyItem()’ – Part 1
- Indiscripts :: On ‘everyItem()’ – Part 2
everyItem()の結果をフィルタリングするやり方が載ってて面白い。 - InDesign自動化サンプルプログラム逆引きリファレンス下 | NextPublishing
- Copy anchored object with specific object style... | Adobe Community
- Tip of the Week: How to Find Tables With Find/Change - InDesignSecrets.com : InDesignSecrets