Copy link to clipboard
Copied
Hi
I've used the following script a lot over the years. It's brilliant, but it changes every table in the document, and now I've come across a situation where I need a script that does the same thing, but just to the table that is selected. I thought I'd seen this discussed somewhere on the forums in the past but I can't find it.
Is it a simple change to make it target just the selected table?
I don't recall where I originally found this script, so apologies to the author.
Thanks in advance to anyone who may be able to assist.
Try this - there is ZERO error checking - so before you run this script - select any Cell - not just text cursor in the Cell - you need to select any Cell.
var myDoc = app.activeDocument;
var myWidths = [60, 10, 10, 10];
var myTable = app.selection[0].parentRow.parent;
for(var j=0; j < myWidths.length; j++){
myTable.columns[j].width = myWidths[j];
}
alert("Table width updated successfully...");
Copy link to clipboard
Copied
Try this - there is ZERO error checking - so before you run this script - select any Cell - not just text cursor in the Cell - you need to select any Cell.
var myDoc = app.activeDocument;
var myWidths = [60, 10, 10, 10];
var myTable = app.selection[0].parentRow.parent;
for(var j=0; j < myWidths.length; j++){
myTable.columns[j].width = myWidths[j];
}
alert("Table width updated successfully...");
Copy link to clipboard
Copied
That's perfect – thanks Robert.
I really appreciate your help.
Copy link to clipboard
Copied
That's perfect – thanks Robert.
I really appreciate your help.
By @stevej61370215
So it works - great to hear. I've made it in the middle of the night, on my phone 😉 Always happy to help.
You could do a lot more - if you work on a PC and don't mind paid solutions 😉
Copy link to clipboard
Copied
I'm on a Mac, but regardless I love this clever timesaving stuff.
I don't get large table-filled reports to do these days as our clients tend to do their reports inhouse, otherwise I'd definitely be looking for a bigger/paid solution.
For the small one-off I'm working on at the moment I've set up multiple copies of your script with different table widths that are common throughout – then I've assigned each version of the script a different keyboard short cut. So your script is definitely making the job more efficient.
Thanks again.
Copy link to clipboard
Copied
I'm on a Mac, but regardless I love this clever timesaving stuff.
Unfortunately, my tool is PC only - for a direct use(*).
For the small one-off I'm working on at the moment I've set up multiple copies of your script with different table widths that are common throughout – then I've assigned each version of the script a different keyboard short cut.
By @stevej61370215
And that's pretty much perfect definition of my tool - save manual clicks / operations as Task(s) - and execute on demand - WITHOUT the need to be a coder / scripter:
(in this case, "Row" / "Column" columns show number of rows / columns in each table, otherwise, they show "address" of the cell)
You can load basic info about all tables in the document - or from selected Story / Selected Text / etc. - then either double-click on the element on the list to select specific table and then execute Task to format it - or checkmark in the first column, tables you want to process - after sorting / filtering by any property - for example number of columns / rows, or applied Table / Cell Style, etc. - and then process them in BatchMode - using the same Task from the top part.
Or you can be in InDesign then use a keyboard shortcut - IDT is monitoring keyboard globally - and execute Task without switching to IDT.
Or you can browse tables in IDT - they can be automatically selected in InDesign for preview - and execute Task using just Keyboard - no mouse needed.
And that's just a tip of an enormous iceberg 😉 But - PC only...
Copy link to clipboard
Copied
Here, I've loaded info about only first 5x selected tables, then used filters to show only Cells from 1st row and 3rd column:
Because, everything user can click in IDT - can also be saved as a command in the Task - user doesn't have to do "pre-processing" on each INDD file - a dedicated Task can prepare "environment" as well.
Or one big Task can select objects to be processed - texts, tables, objects, etc. - and then do processing.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now