Copy link to clipboard
Copied
Hello! I'm trying to find an easier way/script to change table stroke styles from dotted to solid in batch throughout multiple master pages. I made a mistake previously and now I'm having to change all of the dotted lines to solid... Please help!!
"Solid" doesn't work for me! … [french]
Playing with the "cells"! … 😉
// by FRIdNGE, Michel Allio [09/06/20]
var myCells = app.activeDocument.masterSpreads.everyItem().textFrames.everyItem().tables.everyItem().cells.everyItem();
myCells.topEdgeStrokeType = myCells.rightEdgeStrokeType = myCells.bottomEdgeStrokeType = myCells.leftEdgeStrokeType = app.activeDocument.strokeStyles[17];
(^/) The Jedi
Copy link to clipboard
Copied
Hi Channers:
If you used a table style (and perhaps cell styles), you can redefine the style(s) and InDesign will locate all of the tables for you and update the strokes—that is the quickest approach and demonstrates why designing with styles is so important.
Did you use styles? If not, where are the strokes and how did you define them?
~Barb
Copy link to clipboard
Copied
Hi Barb, thank you for your reply! I didn't use styles... the strokes were directly applied to the tables. Like I said, I made a mistake as this document is something I had made when I first learnt InDesign a few months back. I guess I'm going to have to do it manually. Thanks!!
Copy link to clipboard
Copied
Hi there,
Give us something to work upon, a base code that you wrote and that might not be working as per your wants. Tweaks in an existing solution, idea sharing can be done frequemtly but straightaway asking for a readymade solution is a bit being too optimistic. Lets see if someone has something similiar written that can be shared.
-Manan
Copy link to clipboard
Copied
Hi Manan, thanks for your reply! Unfortunately, I'm fairly new to InDesign and I have no idea how scripts work. I've recently enrolled into a Javascript course to help me with this but it's not something that can be learnt overnight. I am looking forward to being able to write codes myself though. Thanks for your help!
Copy link to clipboard
Copied
Try if the following works for you, it will convert all the stroke of all the tables present on every master page in the current document to solid style
var st = app.documents[0].masterSpreads.everyItem().textFrames.everyItem().parentStory
for(var i = 0; i < st.length; i++)
{
var tb = st[i].tables
for(var j = 0; j < tb.length; j++)
{
tb[j].topBorderStrokeType = "Solid"
tb[j].rightBorderStrokeType = "Solid"
tb[j].leftBorderStrokeType = "Solid"
tb[j].bottomBorderStrokeType = "Solid"
}
}
-Manan
Copy link to clipboard
Copied
"Solid" doesn't work for me! … [french]
Playing with the "cells"! … 😉
// by FRIdNGE, Michel Allio [09/06/20]
var myCells = app.activeDocument.masterSpreads.everyItem().textFrames.everyItem().tables.everyItem().cells.everyItem();
myCells.topEdgeStrokeType = myCells.rightEdgeStrokeType = myCells.bottomEdgeStrokeType = myCells.leftEdgeStrokeType = app.activeDocument.strokeStyles[17];
(^/) The Jedi
Copy link to clipboard
Copied
This worked beautifully. Thank you so much Michel!!! Really appreciate it 🙂
Copy link to clipboard
Copied
Thank you for your help Manan!!
Copy link to clipboard
Copied
Hi Michel,
in case the index number of the stroke style will change in future versions of InDesign you could address the style also by name:
myCells.leftEdgeStrokeType =
app.activeDocument.strokeStyles.itemByName("$ID/Solid");
Best,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Hi Uwe,
Personally, I prefer to use an UI and a Stroke Styles pop-up/list like in this script I've written 2 years ago:
I use a "French" InDesign! … So the list would be of course in "German" for you! 😉
Best!
(^/)
Copy link to clipboard
Copied
Hi Michel,
of course it will return the right localized string, why not?
My German InDesign will return the German "Durchgezogen" which stands for "Solid" with that code:
app.activeDocument.strokeStyles.itemByName("$ID/Solid").name
// Result: "Durchgezogen" with my German InDesign
Regards,
Uwe Laubender
( ACP )