• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

LEGEND ,
Dec 10, 2016 Dec 10, 2016

Copy link to clipboard

Copied

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:

Capture d’écran 2016-12-10 à 14.12.48.png

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!

(^/) 

TOPICS
Scripting

Views

355

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 11, 2016 Dec 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.

Votes

Translate

Translate
Community Expert ,
Dec 11, 2016 Dec 11, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 11, 2016 Dec 11, 2016

Copy link to clipboard

Copied

Thanks Peter!

The 2nd code line is cool!

(^/) 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2016 Dec 11, 2016

Copy link to clipboard

Copied

Hi Obi-wan,

so this question here is answered by Peter…

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 11, 2016 Dec 11, 2016

Copy link to clipboard

Copied

LATEST

Oups! … Done with pleasure!  (^/) 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2016 Dec 11, 2016

Copy link to clipboard

Copied

Hi Peter,

thank you very much for this.

Maybe with its introduction in CS4 the enumerator should have been named more like:

TEXT_ANCHOR_NAME_BUILDING_BLOCK

( Something like 'bbta' is not used as enumeration yet… )

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines