7 Replies Latest reply on Dec 23, 2012 10:59 PM by Vamitul

    Find PStyle and apply Cell Style in Table

    BEGINNER_X Level 3

      Hi All,

       

      I am the Beginner. Studying through "InDesignCS3_ScriptingGuide_JS".

       

      Get this script through forum only.

       

       

      Requirement:

       

      In Table i want to find paragraph style (i.e "TBL_COLHD"), for that apply cell style ("TBL_COLHD") etc....

       

       

      Trying Script:

       

      myDoc = app.activeDocument;

       

      app.findTextPreferences = null;

       

      function tableStyle(pStyle, cStyle)

      {

          app.findTextPreferences.appliedParagraphStyle= pStyle;

          myFoundItems = myDoc.findText(true); 

          if (myFoundItems.length != 0) {

                  for (i = 0; i <= myFoundItems.length-1; i++) {

                     var myCell=myFoundItems[i].parent;

                      myCell.appliedCellStyle = cStyle;                //ERROR THIS LINE ONLY

                      myCell.clearCellStyleOverrides(true);

                      }

                  }

              app.findTextPreferences = null;

          }

       

      tableStyle ("TBL_COLHD", "TBL_COLHD");

      tableStyle ("TBL_COLH2", "TBL_COLH2");

       

       

       

      Can anyone give solution for the above mentioned script.

       

       

      Thanks in advance

      BEGINNER