Copy link to clipboard
Copied
Hello,
I hope somebody could help me with a script.
I have tab tekst with a paragraph style and I want to convert that to a table with a table style.
Kind Regards,
Patrick
Yessss
My problem is solved
Thanks a lot.
Patrick
Copy link to clipboard
Copied
function main() {
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.appliedParagraphStyle = "name_of_your_style" //won't work it it's in a style group
var myF = app.activeDocument.selection[0].parentStory.findText(true); //make sure you are inside a text frame when running the script
for (var i = 0; i < myF.length; i++) {
var myTable = myF.convertToTable();
myT.appliedTableStyle = "Name_of_your_Table_style";
myT.clearTableStyleOverrides(); //this line might need to be commented out, see how it works with or without it
}
alert("All done!\nYou can go outside and play now!");
}
app.doScript('main()', undefined, undefined, UndoModes.entireScript, 'AllToTables');
Copy link to clipboard
Copied
Thank you very much
Its working.
I changed tis line:
var myTable = myF.convertToTable();
to
var myT = myF.convertToTable();
Copy link to clipboard
Copied
yep.. sorry about the misstype.
Copy link to clipboard
Copied
Is it also possible to make the width of the total tabel 45mm? in the same script?
So yes what do i have to do.
Copy link to clipboard
Copied
sure.. just add water.. err.. i mean the line:
myT.width=45mm
Copy link to clipboard
Copied
Yessss
My problem is solved
Thanks a lot.
Patrick
Copy link to clipboard
Copied
you are welcome.. but next time please mark the correct answer as correct...
Copy link to clipboard
Copied
Hi,
I tried this script, not work in v2024.
Please help.
Thank you.
Copy link to clipboard
Copied
I tried to get myT.width to work. It errored out. I just cut & paste and even adjusted for syntax with space before and after the = sign.
Copy link to clipboard
Copied
Did you add the semicolon (;) at the end of the line?
Copy link to clipboard
Copied
I did add the semicolon. Maybe it doesn't like that line at the end. ??
Copy link to clipboard
Copied
Did you try commenting out the line
myT.clearTableStyleOverrides();
as suggested by Vamitul?
Copy link to clipboard
Copied
Got it to work.
myT.width = "20p0";
Thanks for all your persistent help — and my 17 yr old for the quotation marks.
Copy link to clipboard
Copied
Good to know. Aren't teenagers great?
Copy link to clipboard
Copied
On this level, yeah !
Copy link to clipboard
Copied
Ok, I have a similar problem except that the paragraph styles I am looking for and wish to apply ARE both within Style Groups that are up to 3 levels deep. What has to change in this script so it will find & replace with whichever paragraph styles are pass to the function regardless of their Style Group depths? Additionally, it's possible that certain documents may not have all the styles and/or groups that I am looking for so how do I prevent the script from failing if it encounters such?
Copy link to clipboard
Copied
Hi Vamitul,
This script after the update of the line "var myT = myF.convertToTable();" is not working.
Thank you.
Copy link to clipboard
Copied
Hi,
Finally, this script is working but very slow in a 350-page document.
Thank you.
Copy link to clipboard
Copied
Hi,
How did you get it to work? I get the error
Error string: myF.convertToTable is not a function.
Thank you.
Copy link to clipboard
Copied
Dear Vamitul,
I am trying to get this script to work on InDesign 18.5.2, but so far no luck. Do you know what should be updated to get this to work?
Thank you, Peter
Copy link to clipboard
Copied
Hi @pjgjpg,
I think you have got response on this in the other thread. For anyone looking for answers to this please see https://community.adobe.com/t5/indesign-discussions/indesign-script-for-paragraph-style-to-tables/m-...
-Manan