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

Highlight clicked to text

Explorer ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

In inDesign, is there a way to highlight a piece of text that has been clicked to from another page? For example, a button from page 2, when clicked, would go to a table with rows. Can I highlight a row, or text like this through code?

William225192357fw1_0-1648844059402.png

 



TOPICS
How to , Scripting , Type

Views

178

Translate

Translate

Report

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 ,
Apr 04, 2022 Apr 04, 2022

Copy link to clipboard

Copied

Hi William,

do you like a selection of text like you do it without a script or do you like to address the text to apply a certain formatting or whatever? Both can be done by scripting. The difference: In a table you can do only one single selection of text in a cell at one time.

By addressing the cell and its text without selecting it you could run either a loop that visits every table in your table document or, if this is your goal, you could address every third cell in the first column of every table in your document in one go. See code below.

 

Read into:

 

On ‘everyItem()’ – Part 2
Marc Autret, July 19, 2010

https://www.indiscripts.com/post/2010/07/on-everyitem-part-2

 

Marc Autret says:

"Note. — Contrary to popular belief, it is not necessary that each document hosts 3 groups to set app.documents.everyItem().groups[2] as a container. It suffices that at least one document satisfies this requirement."

 

That means, in your case it needs at least one table in your document with a third text cell in the first column to address this one ( and all other ones if there are any ) and theit texts with:

 

 

/*
Change formatting of fill color of every text in 
the third cell of the first column 
of every table in the document
*/
app.documents[0].stories.everyItem().tables.everyItem().columns[0].cells[2].texts[0].properties =
{

	// Just an example:
	fillColor : app.documents[0].colors.itemByName("Black")

	// Add other property / value pairs if you like below

};

 

 

Also possible:

You build your own UI with e.g. ScriptUI to select all instances one after another.

But this requires more effort than a couple of code lines.

 

Regards,
Uwe Laubender

( ACP )

 

//EDITED

Votes

Translate

Translate

Report

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
Explorer ,
Apr 06, 2022 Apr 06, 2022

Copy link to clipboard

Copied

Thank you for replying; I don't even know where to start with scripting. With my Flash experience and action script I would have applied an onClick() to a button, or text link and then when it jumped to a page, I could pass a command to highlight the text in the table. Not that simple it seems in inDesign. It's probably not done that much, but seems like an intuitive piece of code; especially with text dense documents. I'll keep trying. Any other clues on where to apply the code would be great. thank you.

Votes

Translate

Translate

Report

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 ,
Apr 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

LATEST

Flash with ActionScript is a totally different thing compared with ExtendScript and InDesign.

Something like highlighting (selecting) all text in a table is simply not possible in InDesign.

Not with the GUI, not by scripting.

 

What you can do is select all cells in a table. Or all cells of a certain table row. In the GUI and by scripting.

 

Identify a certain table first. That's perhaps the hardest part to do. You need to start somewhere. Just an example below. If you have the text frame of a table selected in the GUI where there is only one table in the story of this text frame this goes like that:

var myTable = app.selection[0].parentStory.tables[0];

If you now want to select the second row for example, use variable myTable like that:

app.select( myTable.rows[1] );

Or do it like that:

myTable.rows[1].select();

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

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