Skip to main content
Participant
June 11, 2024
Question

Indesign script for Paragraph Style to Tables

  • June 11, 2024
  • 3 replies
  • 477 views

Dear all,

 

I am trying to get the script to work that was posted here in 2013: https://community.adobe.com/t5/indesign-discussions/script-for-indesign-find-paragraph-style-change-to-table-with-table-style/m-p/5149526

 

So far, it does not work, as I suspect it is outdated. Can anyone help me get it to work on INDD 18.5.2? Basically I would like to convert all paragraph that have a certain paragraph style to tables, and apply a table style.

 

So far, I get this error:

 

Any help would be greatly appreciated!

 

Best, Peter

This topic has been closed for replies.

3 replies

Community Expert
June 12, 2024

I think the script would execute fine on the current version of InDesign as well. Two things to change though

So the correct code would be

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 myT = myF[i].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');

-Manan

-Manan
Mike Witherell
Community Expert
Community Expert
June 11, 2024

Did you try putting that old script in a subfolder (under the Scripts folder) named "Version 9.0 Scripts"?

Mike Witherell
brian_p_dts
Community Expert
Community Expert
June 11, 2024

myF needs to be myF[i]

 

Iterators were stripped in old forum migration