Skip to content

Instantly share code, notes, and snippets.

@UskeS
Last active Feb 25, 2020
Embed
What would you like to do?
[InDesign]選択したセルの高さを変更する
/**
* @fileoverview 選択したセルの高さを変更する
* @author Yusuke SAEGUSA
* @version 0.0.1
*/
if (app.documents.length === 0) {
exit();
}
if (app.activeDocument.selection.length !== 1) {
alert("セルか表ひとつを選択してください");
exit();
}
var doc = app.activeDocument;
var sel = doc.selection[0];
if (sel instanceof Table || sel instanceof Cell) {
sel = sel.cells;
} else {
alert("セルか表ひとつを選択してください");
exit();
}
var dlg = new Window("dialog {alignChildren: ['fill','center'], spacing: 8}", "changeCellHeight");
dlg.add("staticText", undefined, "設定値");
var input = dlg.add("editText {preferredSize:[30,-1]}");
var chb = dlg.add("checkBox", undefined, "指定値を使用");
chb.value = true;
var btn = dlg.add("button", undefined, "実行", {name:'ok'}).onClick = function() {
dlg.close(1);
}
var result = dlg.show();
if (result === 2) {
exit();
}
//-- main --//
for (var i=0, len=sel.length; i<len; i++) {
sel[i].height = input.text;
sel[i].autoGrow = !chb.value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment