Skip to main content
Obi-wan Kenobi
Legend
December 10, 2016
Answered

Code to be evaluated! [009] Cross-Reference Format! …

  • December 10, 2016
  • 1 reply
  • 483 views

Hi all Scripters,

I've an exasperating issue with the cross-reference format definition in [JS]!

With this code:

var myDoc = app.activeDocument;

var myCRFormat = myDoc.crossReferenceFormats.add ('myTest'); 

var myCRCharStyle = myDoc.characterStyles.itemByName("Superscript");

myCRFormat.appliedCharacterStyle = myCRCharStyle;

myCRFormat.buildingBlocks.add ({blockType: BuildingBlockTypes.CUSTOM_STRING_BUILDING_BLOCK, customText: '<txtAnchrName/>'}); 

I get this:

Grrr!!! 

Moreover, I find this code not frankly cool to read! Could we add "myCRFormat" directly playing with properties?

Thanks in advance for your comments!

(^/) 

This topic has been closed for replies.
Correct answer Peter Kahrel

Use a named building block for the anchor:

myCRFormat.buildingBlocks.add ({blockType: BuildingBlockTypes.CUSTOM_STRING_BUILDING_BLOCK, customText: 'On this page: '});

myCRFormat.buildingBlocks.add ({blockType: BuildingBlockTypes.BOOKMARK_NAME_BUILDING_BLOCK});

The Adobe chaps got it slightly wron when they used 'Bookmark' when the meant 'Anchor'.

P.

1 reply

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
December 11, 2016

Use a named building block for the anchor:

myCRFormat.buildingBlocks.add ({blockType: BuildingBlockTypes.CUSTOM_STRING_BUILDING_BLOCK, customText: 'On this page: '});

myCRFormat.buildingBlocks.add ({blockType: BuildingBlockTypes.BOOKMARK_NAME_BUILDING_BLOCK});

The Adobe chaps got it slightly wron when they used 'Bookmark' when the meant 'Anchor'.

P.

Obi-wan Kenobi
Legend
December 11, 2016

Thanks Peter!

The 2nd code line is cool!

(^/) 

Community Expert
December 11, 2016

Hi Obi-wan,

so this question here is answered by Peter…

Regards,
Uwe