0 Replies Latest reply on Jul 31, 2012 2:58 AM by ankit_1052

    How to add new Element using ExtendScript

    ankit_1052

      I need to create a script which look for all tables in a FM file and will add “TableContinuation” Element if not available. I am able to search all tables not having “TableContinuation” element within “TCaption” element. But not able to add New Element using ExtendScript. Could you please help me over here? Bwlow is the function I wrote to add new element. Thank You.


      function Table_Continuation()

      {

          var flow = app.ActiveDoc.MainFlowInDoc;

          var tbl;

          var textItems = flow.GetText(Constants.FTI_TblAnchor);

       

          for (var i = 0; i < textItems.len; i += 1)

          {

              tbl = textItems[i].obj;

       

              if(tbl.TblTitlePosition != 0)

              {

                  var title = tbl.TblTitleElement;

                  if(title.ElementType == 9)

                  {

                      var Caption = title.FirstChildElement;

                      var TableCon = Caption.FirstChildElement;

                     

                      if(!TableCon.ObjectValid())

                      {

                          //  Here goes the code to add element named "TableContinuation"

                      }

                  }  

              }

          }

      }