Skip to main content
Inspiring
November 20, 2019
Question

Script to search for Borders and Shading

  • November 20, 2019
  • 3 replies
  • 1179 views

Does anyone know where to find, or happen to have a script that can search for paragraphs with borders and shading applied? (I am looking for something that can search for a graf with a border applied and replace that with a different paragraph style).  

 

Thank you for any help.

This topic has been closed for replies.

3 replies

Jongware
Community Expert
Community Expert
November 21, 2019

Looking through the new API documentation at https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FindTextPreference.html (thanks, Gregor!), I can indeed find nothing related to paragraph shading and borders in the FindTextPreferences.

So while we await for Adobe to catch up with this, it seems to me there is no other option than the old, painfully slow Loop Over All Paragraphs and Test Them One By One approach. "Testing all" is my least favourite workaround in the entire DOM because this value of "all" doesn't always mean "all of everything that I want here", and different approaches lead to different values for "all"... Plus, there is not a single 'best' approach that catches 'everything', 'most', or, indeed, 'anything useful at all'.

 

Each paragraph needs a bit of testing, too: first, of course, the property paragraphShadingOn -- if this is off then the answer is "no". However, if it is on, you still need to test if the fill is not [None] or the background color, if its fill tint is not 0%, and optionally if it's set to Not Printing.

Inspiring
November 21, 2019

Thank you so much for checking into this. It looks like the best option will be to go through all 900 or so pages and look for all the paragraphs with "Normal+border" or "heading1+border" and change them manually. Sigh. Thrilled it is possible to finally have borders at all though!

Jongware
Community Expert
Community Expert
November 21, 2019
hammer0909
Community Expert
Community Expert
November 21, 2019

Although you can't directly search for the borders and shading properties using Find/Change, you can search for them if you have a paragraph style applied. Using Find/Change, click on the "specify attributes to find" button in the Find Format section and choose the style that is applied. Then you can replace it in the Change Format section.

 

Inspiring
November 21, 2019

Well, yes, that would be lovely. But of course these were set up in Word (where you also can't search for borders) and they use styles like "Heading 1" and "Normal". So my goal (there are about 900 pages of material) was to find all the paragraphs (regardless of the style applied) and change those with borders to have a new style all their own. Thanks for the reply though.