2 Replies Latest reply on Aug 28, 2014 4:26 AM by uvarajms

    Hi my requirement is, In table I would like to give “equal column space” from the second column to end column of table. My code is below. Please resolve my error code and my requirement.

    uvarajms

      var myDoc = app.activeDocument;

      myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

      myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

          var myTable = app.selection[0].paragraphs[0].tables[0];

          myColumns = myTable.columns.count();

          myRows = myTable.rows.count()

           var myCs = new Array;  

              for (var c = 0; c < myColumns; c++)

                  {

                      myCMaxWidth = 0;

                      for (a=0; a< myRows; a++) {

                          if (myTable.rows[a].columns.length!=myTable.rows[a].cells.length) {

                              continue;

                              }

                          try {

                          myOutText = myTable.rows[a].cells[c].texts[0].createOutlines (false);

                          } catch (err) {

                              continue;

                              }

                          myC1Width = myOutText[0].geometricBounds[3] - myOutText[0].geometricBounds[1]

                          myOutText [0]. remove();

                          if (myCMaxWidth < myC1Width) {

                              myCMaxWidth = myC1Width;

                              }

                           }

                       myCs.push(myCMaxWidth);

                       myTable.columns[c].width = myCMaxWidth;

       

                  }

       

               var myTableWidth = myTable.width;

              var myTableColWidths = myTable.columns.everyItem().width;

              var myColumns = myTable.columns.count();

              var myTableParent = myTable.parent;

              var myParentWidth = myTableParent.textFramePreferences.textColumnFixedWidth;

              var myAdjustment = (myParentWidth - myTableWidth)/myColumns;

              for (var c = 0; c < myColumns; c++)

                  {

                      myTable.columns[c].width = myTableColWidths[c] + myAdjustment;

                  }