Help with a Table Script
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Help with a Table Script
- This topic has 5 replies, 2 voices, and was last updated 6 years, 7 months ago by Kelli Fleck.
-
AuthorPosts
-
-
September 8, 2017 at 7:20 am #97891Kelli FleckMember
I am editing a table script I have. I have these two lines but I don’t know how exactly to modify it so it will do what I want.
table.rows.everyItem().cells.everyItem().paragraphs.everyItem().appliedParagraphStyle = paragraphStyle(‘Table’, ‘Table – Body Text’); // Apply “Table – Body Text” to all text
table.rows.everyItem().cells.everyItem().paragraphs.everyItem().appliedParagraphStyle = paragraphStyle(‘Table’, ‘Table – Body Number’); // Apply “Table – Body Numbers” to all numbersI want to apply the style “Table – Body Text” to cells that contain letters but may also contain numbers.
I want to apply the style “Table – Body Numbers” to cells that contain ONLY numbers.Can anyone help me? Please. :)
Kelli
-
September 8, 2017 at 8:20 am #97894Mike DeanMember
I think the easiest thing would be to leave the first line as is so it styles everything with the main body text style, then replace the second line with a GREP search that will find all number-only cells within that style and table.
So the second line would be replaced with something like this:
//create variables for paragraph styles
var tableBodyStyle = paragraphStyle(‘Table’, ‘Table – Body Text’);
var tableNumberStyle = paragraphStyle(‘Table’, ‘Table – Body Number’);//GREP to find text that only contains numbers, comma separator, or decimal, currency symbol
app.findGrepPreferences.findWhat = “^[\\d,\\.\\$]+$”; //this can be reduced if you only need digits
app.findGrepPreferences.appliedParagraphStyle = tableBodyStyle;
app.changeGrepPreferences.appliedParagraphStyle = tableNumberStyle;//search within current table
table.changeGrep(); -
September 8, 2017 at 11:07 am #97901Kelli FleckMember
Thank you!! I will try this.
-
September 8, 2017 at 12:13 pm #97902Kelli FleckMember
So this script works and I can see the GREP in the FIND/CHANGE but it isn’t applying to all. I am missing a command line I think.
-
September 8, 2017 at 12:14 pm #97903Kelli FleckMember
Oh I see the command
table.changeGrep();But my error says “table is undefined”
Ill keep seeing if I can fix that. :)
-
September 8, 2017 at 12:20 pm #97904Kelli FleckMember
I GOT IT TO WORK! THANK YOU!!! :)
-
-
AuthorPosts
- You must be logged in to reply to this topic.