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

Script for Indesign find paragraph style change to table with table style

Explorer ,
May 30, 2013 May 30, 2013

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

TOPICS
Scripting
7.1K
Translate
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

correct answers 1 Correct answer

Explorer , May 31, 2013 May 31, 2013

Yessss

My problem is solved

Thanks a lot.

Patrick

Translate
Advisor ,
May 31, 2013 May 31, 2013

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');

Translate
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 ,
May 31, 2013 May 31, 2013

Thank you very much

Its working.

I changed tis line:

var myTable = myF.convertToTable();

to

var myT = myF.convertToTable();

Translate
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
Advisor ,
May 31, 2013 May 31, 2013

yep.. sorry about the misstype.

Translate
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 ,
May 31, 2013 May 31, 2013

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.

Translate
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
Advisor ,
May 31, 2013 May 31, 2013

sure.. just add water.. err.. i mean the line:

myT.width=45mm

Translate
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 ,
May 31, 2013 May 31, 2013

Yessss

My problem is solved

Thanks a lot.

Patrick

Translate
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
Advisor ,
May 31, 2013 May 31, 2013

you are welcome.. but next time please mark the correct answer as correct...

Translate
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
New Here ,
Apr 29, 2024 Apr 29, 2024

Hi, 
I tried this script, not work in v2024.
Please help. 

Thank you.

Translate
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
Contributor ,
Jun 21, 2013 Jun 21, 2013

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.

Translate
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 ,
Jun 21, 2013 Jun 21, 2013

Did you add the semicolon (;) at the end of the line?

Translate
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
Contributor ,
Jun 21, 2013 Jun 21, 2013

I did add the semicolon.  Maybe it doesn't like that line at the end.  ??

script.png

Translate
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 ,
Jun 21, 2013 Jun 21, 2013

Did you try commenting out the line

myT.clearTableStyleOverrides();

as suggested by Vamitul?

Translate
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
Contributor ,
Jun 21, 2013 Jun 21, 2013

Got it to work.  

myT.width = "20p0";

Thanks for all your persistent help — and my 17 yr old for the quotation marks.   

Translate
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 ,
Jun 21, 2013 Jun 21, 2013

Good to know. Aren't teenagers great?

Translate
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
Contributor ,
Jun 21, 2013 Jun 21, 2013

On this level, yeah !

Translate
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 ,
May 29, 2015 May 29, 2015

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?

Translate
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
New Here ,
Apr 29, 2024 Apr 29, 2024

Hi Vamitul,

This script after the update of the line "var myT = myF.convertToTable();" is not working.

Thank you.

Translate
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
New Here ,
Apr 29, 2024 Apr 29, 2024

Hi,

Finally, this script is working but very slow in a 350-page document. 

Thank you.

Translate
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 Beginner ,
Jun 11, 2024 Jun 11, 2024

Hi,

How did you get it to work? I get the error 

 

Error string: myF.convertToTable is not a function.

 

Thank you.

Translate
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 Beginner ,
Jun 11, 2024 Jun 11, 2024

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

Translate
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 ,
Jun 11, 2024 Jun 11, 2024
LATEST

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

Translate
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