Skip to main content
Jameel Bin Abdallah
Known Participant
May 7, 2021
Answered

Script to find Text Frame By Paragraph Style

  • May 7, 2021
  • 1 reply
  • 894 views

Hy guys, please someone should help me with a script to do this.

 

I want to find a text frame with paragraph style “CASES”  across my documents of more than 500 pages, then change the text frame vertical alignment option to “center”.

 

I.e. 

From This

To This

Thanks

 

 

{Renamed by MOD}

This topic has been closed for replies.
Correct answer brian_p_dts

Is there anything about the frame you can search for via Object settings, using the Find Object dialog box? 

 

If not, rudimentarily (Change 'P Style Name to Find' to the paragraph style name in question): 

var tfs = app.activeDocument.textFrames.everyItem().getElements();
for (var i = 0; i < tfs.length; i++) {
    try { 
        if (tfs[i].insertionPoints[0].appliedParagraphStyle.name == "P Style Name to Find") { 
            tfs[i].textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
        }
    } catch(e){}
}

 

1 reply

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
May 7, 2021

Is there anything about the frame you can search for via Object settings, using the Find Object dialog box? 

 

If not, rudimentarily (Change 'P Style Name to Find' to the paragraph style name in question): 

var tfs = app.activeDocument.textFrames.everyItem().getElements();
for (var i = 0; i < tfs.length; i++) {
    try { 
        if (tfs[i].insertionPoints[0].appliedParagraphStyle.name == "P Style Name to Find") { 
            tfs[i].textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
        }
    } catch(e){}
}

 

Jameel Bin Abdallah
Known Participant
May 8, 2021

Wooow,

It worked perfectly well just like magic. Everything happened in 3 seconds.

Really appreciate bro.

Am seriously excited.

Thanks you.

Thank you

Thank you.