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

Defining a Cross-Reference format via script

Contributor ,
May 01, 2025 May 01, 2025

Hi everyone,

From this old post, I've learned that it's possible to create a cross-reference to paragraph via script. My question now is: Is there a way to also define/edit it via script? - see screenshot below. For instance, I would like to remove the quotations marks and leave only <paraText /> when creating the cross-reference. @Peter Kahrel, any help will be greatly appreciated 🙂 Thanks!

Rogerio5C09_0-1746128846061.png

 

TOPICS
Scripting
133
Translate
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 ,
May 01, 2025 May 01, 2025
Translate
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 ,
May 05, 2025 May 05, 2025
LATEST

@Rogerio5C09 -- The thing with editing cross-refernce formats is that you can't remove individual items: you have to remove all parts, then add what you want:

 

cr = app.activeDocument.crossReferenceFormats.item ('Paragraph Text');

// Can't remove the lot using everyItem().remove(),
// so you have to remove each item separately

for (i = cr.buildingBlocks.length-1; i >= 0; i--) {
  cr.buildingBlocks[i].remove();
}

// Add the desired building block

cr.buildingBlocks.add (BuildingBlockTypes.PARAGRAPH_TEXT_BUILDING_BLOCK);
Translate
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