Shifting table contents globally ‘left’ and ‘right’ into previous and next rows, is not a usual table task. If a table column is not aligned correctly with another, you can copy-and-paste the wrong content one position to the left or right. But that won’t work with ‘row wrap’.
Fortunately, it can be scripted. Here are shiftup.jsx
and shiftdown.jsx
. They move the *text content* of a table one cell left or right – unless there is something in the first (or last) cell, of course!
//DESCRIPTION:Shift table cells 'up'
// A Jongware Script 21-May-2015
currTable = app.selection[0];
if (currTable.hasOwnProperty('baseline'))
currTable= app.selection[0].parent;
while (currTable instanceof Cell || currTable instanceof Row || currTable instanceof Column)
currTable = currTable.parent;
if (currTable instanceof Table)
{
if (currTable.cells[0].texts[0] &&
currTable.cells[0].texts[0].length > 0)
{
alert ("no room to shift up!");
} else
{
for (i=1; i<currTable.cells.length; i++)
currTable.cells[i].texts[0].move (LocationOptions.AT_BEGINNING, currTable.cells[i-1]);
}
} else
{
alert ("please make sure the cursor is inside a table!");
}
and
//DESCRIPTION:Shift table cells 'down'
// A Jongware Script 21-May-2015
currTable = app.selection[0];
if (currTable.hasOwnProperty('baseline'))
currTable= app.selection[0].parent;
while (currTable instanceof Cell || currTable instanceof Row || currTable instanceof Column)
currTable = currTable.parent;
if (currTable instanceof Table)
{
if (currTable.cells[-1].texts[0] &&
currTable.cells[-1].texts[0].length > 0)
{
alert ("no room to shift down!");
} else
{
for (i=currTable.cells.length-2; i>=0; i--)
currTable.cells[i].texts[0].move (LocationOptions.AT_BEGINNING, currTable.cells[i+1]);
}
} else
{
alert ("please make sure the cursor is inside a table!");
}