Kopieren einer formatierten Tabellenzelle ohne Copy/Paste
Code: Alles auswählen
// © 2015 by Werner Perplies, EDV-Anwendungsberatung,
// https://www.weepee.de, email: werner.perplies@weepee.de
// created: Wed Nov 25 2015 07:53:26 GMT+0100
// usage:
// must be defined _before_ calling, best - start of script
// sourceCell.copyFormattedText(targetCell)
// sourceCell.copyFormattedText(targetCell, false|true)
// sourceCell.copyFormattedText(targetCell, false|true, LocationOptions.AT_END|LocationOptions.AT_BEGINNING)
/*void*/Cell.prototype.copyFormattedText=function(/*Cell*/cell, /*Boolean*/deleteContent, /*Enum*/to)
{
if (deleteContent === undefined)
{
deleteContent = true;
}
if (deleteContent)
{
if (cell.texts[0].contents.length > 0)
{
cell.texts[0].remove();
}
}
if (to === undefined)
{
to = LocationOptions.AT_END;
}
if (this.texts[0] != null)
{
this.texts[0].duplicate(to, cell);
}
}
// example
main();
/*void*/function main()
{
var /*Cells*/CellsInFirstTableInFirstStory = app.activeDocument.stories[0].tables[0].cells,
/*Cell*/firstCell = CellsInFirstTableInFirstStory[0],
/*Cell*/lastCell = CellsInFirstTableInFirstStory[CellsInFirstTableInFirstStory.length-1];
firstCell.copyFormattedText(lastCell, false, LocationOptions.AT_BEGINNING);
}