DTP駆け込み寺

No.20655へ返信

記事投稿フォーム
補助
送信

[ 返信 ]

表に対して縦方向への流し込みスクリプト

インデザインCC2014
表の内容を縦方向(列方向)へ改行続きのテキストを流し込むスクリプトを考えているところなのですが、うまく動かず苦戦しております。

「Table Replace.scpt」は行方向への流し込みですのでこれを流用すれば列方向にもいけるはず…?といろいろと触っている内に二進も三進もいかず…。

よろしければご教授願えませんでしょうか

市川せうぞー様「Table Replaceもどき より改変」
http://www.seuzo.jp/rubbs/search_html/msg01462.html

CR = String.fromCharCode(13); //改行
TAB = String.fromCharCode(9); //タブ
TBL = String.fromCharCode(0x16); //表組

if (app.selection.length == 1){
var tblObj = app.selection[0];
switch (app.selection[0].constructor.name){
case "Cell":
case "Table":
case "Column":
case "Row":
break;
default:
break label;
}
var clipAry = new Array();
var myDoc = app.activeDocument;
with (txtfrmObj = myDoc.textFrames.add()){
visibleBounds = ["0cm","0cm","18cm","21cm"];
contents = "ダミー";
app.selection = characters.itemByRange(0,-1);
app.paste();
while (characters[-1].contents == CR) characters[-1].remove(); //最後の改行を削除
var clipstr = "" + contents;
}
if (clipstr == TBL){
clipAry = txtfrmObj.tables[0].contents;
} else if (clipstr != ""){
var tmparray = clipstr.split(CR);
for (var i=0; i < tmparray.length; i++)
clipAry = clipAry.concat(tmparray[i].split(TAB));
}
txtfrmObj.remove();

if (tblObj.cells.length == clipAry.length){
var sel = app.activeDocument.selection;
var tblObjCol = sel.tables.columns.cells;
try {
tblObjCol.contents = clipAry;
}
catch(e) {
alert("表組への貼付けに失敗しました。");
}
}
label:
}

[20655] 双葉マークP (2021/10/25 Mon 17:25)