Tabellenzelleninhalt in Zelle kopieren

Funktionen, Klassen, Prototypes, Libraries, Problemlösungen
Antworten
wernerperplies
Beiträge: 250
Registriert: 6. Aug 2011, 17:48
Wohnort: 18374 Zingst
Kontaktdaten:

Tabellenzelleninhalt in Zelle kopieren

Beitrag von wernerperplies » 25. Nov 2015, 11:27

Als Antwort auf diese Frage:
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);
        }
         
einen schönen Tag wünscht

Werner Perplies
https://www.weepee.de

Antworten

Zurück zu „Snippets und Libs“