Copy link to clipboard
Copied
This script is meant to change in each paragraph, the characters after the "," to a smaller character style.
It's not functioning as designed. Currently I can get it to count the characters but the "Start_changing" variable never changes from zero. Basically I have the possibility of 6 names in a list, all with alphabet soup after the comma and before the return. Any help would be greatly appreciated.
// --- person's degree in smaller font
var HealthNameBlock;
HealthNameBlock = InDesign_Document.layers.item("nameblock").textFrames.item(0);
var HealthAddressBlock;
HealthAddressBlock = InDesign_Document.layers.item("addressblock").textFrames.item(0);
var HealthNameStory;
HealthNameStory = HealthNameBlock.parentStory;
var Start_changing;
Start_changing = 0;
var Paragraph_character_counter;
var Story_character_counter;
if(HealthNameStory.paragraphs.count() > 0)
{
for(Paragraph_counter = 0 ; Paragraph_counter < HealthNameStory.paragraphs.count() ; Paragraph_counter++)
{
for(Paragraph_character_counter = 0 ; Paragraph_character_counter < HealthNameStory.paragraphs.item(Paragraph_counter).characters.count() ; Paragraph_character_counter++)
{
if(HealthNameStory.paragraphs.item(Paragraph_counter).characters.item(Paragraph_character_counter).contents == "," && Start_changing == 0 && HealthNameStory.paragraphs.item(Paragraph_counter).characters.item(Paragraph_character_counter).appliedParagraphStyle == "Name")
{
Start_changing = Paragraph_character_counter + 1;
};
};
};
};
if(Start_changing > 0 )
{
for(Story_character_counter = Start_changing ; Story_character_counter < HealthNameStory.paragraphs.item(Paragraph_counter).characters.count() ; Story_character_counter++)
{
if(HealthNameStory.paragraphs.item(Paragraph_counter).characters.item(Story_character_counter).appliedParagraphStyle == "Name")
{
HealthNameStory.paragraphs.item(Paragraph_counter).characters.item(Story_character_counter).appliedCharacterStyle = InDesign_Document.characterStyles.item("degree_smalltext");
};
};
};
Copy link to clipboard
Copied
Too early for me to dissect that code, but you can just use a GREP style in your name Paragraph Style definition.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now