[GastForen

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste
Forenindex -- Lesezeichen

1 Lesezeichen für tabellenzeile

Querverweis in Text umwandeln
Der Name der Seite, auf der eine Tabellenzelle liegt, lässt sich also etwa mit folgendem Konstrukt ermitteln.

Code
// Vor Ausführung Einfügemarke in Tabellenzelle platzieren!  

var doc = app.documents.firstItem();
var s = app.selection[0].insertionPoints.firstItem();

var cr_name = 'Seite';
var cr_format = doc.crossReferenceFormats.itemByName(cr_name);
if (cr_format == null)
{
cr_format = doc.crossReferenceFormats.add({name:cr_name});
cr_format.buildingBlocks.add({blockType:BuildingBlockTypes.PAGE_NUMBER_BUILDING_BLOCK});
}

var cr_source = doc.crossReferenceSources.add ( {sourceText:s, appliedFormat: cr_format} );
var cr_destination = doc.hyperlinkTextDestinations.add ( {destinationText: s } );
var cr = doc.hyperlinks.add ( cr_source, cr_destination );

var str = cr_source.sourceText.textVariableInstances[0].resultText;

cr.remove();
cr_source.sourceText.remove();
cr_destination.remove();

alert('Seite: ' + str);

...
Martin Fischer
1. Feb 2012, 00:02