Skip to main content
Inspiring
February 8, 2023
Answered

how to find tables and change the paragraph style in them?

  • February 8, 2023
  • 2 replies
  • 798 views

Dear Smart Indesigners!

I'm trying to get my work done quicker, and am searching for a solution to find tables in my text and change the paragraph style in said tables. I found a few solutions here in this community but they didnt seem to work. Maybe that has to do with me being not so used to scripting and GREP?

Thank you so much!

Caro

 

This is what I tried, (didn't understand it comletely)

Instructions:

(1) Set up your text find/change however you want (change styles, etc. etc.)

(2) Don't click on Change All. Instead, run the following script. It will perform the find/change you've set up, but in tables only. (Not tested with weird things like tables in tables, tables in footnotes, etc. But definitely works with top-level tables).

document.stories.everyItem().tables.everyItem().changeText();

If you want to use InDesign's GREP find/change inst

This topic has been closed for replies.
Correct answer Caroline de Lint

That looks like different code than the single line script: 

app.activeDocument.stories.everyItem().tables.everyItem().changeText();


OMG it worked!!! Brian You are a GENIUS!!! Thank you so much!!!

2 replies

John Mensinger
Community Expert
Community Expert
February 8, 2023

This doesn't necessarily answer your question the way you asked it, but rather than struggle with a script, here's what I'd do:

  1. Make a copy of the paragraph style in question by dragging it to the New Style button at the bottom of the Paragraph Styles panel. Rename it if you want, or just leave the automatcally added "Copy" at the end of the name.
  2.  Do a Find (format)/Change to change all the frame-based (not in tables) paragraphs, if there are any, from the original style to the copy made in step 1.
  3.  Edit the original style (now only applied in tables thanks to step 2), to change and apply the new styling you want in the tables.
Inspiring
February 8, 2023

Yes, that would be lovely! But I don't know how to find "all the frame-based (not in tables) paragraphs"...

Thank you for your quick reply, John!

John Mensinger
Community Expert
Community Expert
February 8, 2023
  1. In the Find/Change dialog, click the Specify Attributes button next to the Find Format field:

    That will open the Find Format dialog, where you can choose the paragraph style to find...

  2. Similarly, click the click the Specify Attributes button next to the Change Format field:

    ...and choose the paragraph style to serve as the replacement...

     

brian_p_dts
Community Expert
Community Expert
February 8, 2023

Try hitting Find Next first, to save the FC query so that the script can read it. If you just set the find/change parameters but don't hit Find Next then the script won't see the values. 

Inspiring
February 8, 2023

Dear Brianp311, thank you, but the problem seems to be that I didnt understand the original solution, I made a script with document.stories.everyItem().tables.everyItem().changeText(); but got an error:

So I think I made a mistake in the script... Thanks for your quick reply!

brian_p_dts
Community Expert
Community Expert
February 8, 2023

That looks like different code than the single line script: 

app.activeDocument.stories.everyItem().tables.everyItem().changeText();