5 Replies Latest reply on Mar 30, 2015 8:28 PM by Johnwhite

    Add empty return at end of story

    Johnwhite Level 1

      Hi experts

       

      How can make a script for add some empty return at end of sotry, not matter the end is a table without any return?

       

      Thanks

      Regard

      John

        • 1. Re: Add empty return at end of story
          Loic.Aigon Adobe Community Professional

          Hi,

           

          You may want to target the last insertionPoint Object of any single Story Object of the document and then fill in the carriage return:

           

          app.activeDocument.stories.everyItem().insertionPoints[-1].contents = "\r";
          

           

           

          HTH,

           

          Loic

          http://www.ozalto.com

          • 2. Re: Add empty return at end of story
            hamdifem Level 1

            How can we put the last all paragraph in the story

            • 3. Re: Add empty return at end of story
              Johnwhite Level 1

              Thank you Loic, thank you so much!

               

              Could you please tell me how to add characters into empty cells.

               

              for example, I want to add [~8] into every tables' empty cells, how can I do that?

               

              Regard

              John

              • 4. Re: Add empty return at end of story
                Chinnadk Level 4

                Try this,

                 

                var doc = app.activeDocument;
                var _cells = doc.stories.everyItem().tables.everyItem().cells.everyItem().getElements();
                for(var i =0;i<_cells.length;i++)
                {
                        if(_cells[i].contents == "")
                        {
                                _cells[i].contents = "[~8]"
                            }
                    }
                

                 

                Regards,

                Chinna

                • 5. Re: Add empty return at end of story
                  Johnwhite Level 1

                  Thank you Chinna

                  thank you so much

                   

                  this script as below function for remove empty column, but in active doc

                  now I only need it work in selection[0]

                  could you please help me change it only work in app.selection[0]?

                   

                   

                   

                  myDoc = app.activeDocument;
                  findTable();

                  function findTable(){
                  for ( s = myDoc.stories.length-1; s >= 0; s-- ){
                    for ( t = myDoc.stories[s].tables.length-1; t >= 0; t-- ){
                     myTable = myDoc.stories[s].tables[t];
                     removeCurrentColumn();
                    }
                  }
                  }

                  function removeCurrentColumn(){
                  for ( i = myTable.columns.length-1; i >= 0; i-- ){
                     if (currentColumnIsEmpty(i) == true){
                     myTable.columns[i].remove();
                    }
                  }
                  }

                  function currentColumnIsEmpty(col){
                      theColumnIsEmpty = true;
                  for ( k = myTable.rows.length-1; k >= 0; k-- ){
                    if (myTable.cells.item(col + ":" + k).texts[0].contents != ""){
                     theColumnIsEmpty = false;
                    }
                  }
                    return theColumnIsEmpty;
                  }

                  function findTableDel(){
                  if (myDoc.stories.everyItem().tables.length > 0) {
                    myAllTables = myDoc.stories.everyItem().tables.everyItem();
                    for ( s = myAllTables.length-1; s >= 0; s-- ){
                     myTable = myAllTables.item[s];
                     removeCurrentColumn(myAllTables[s]);
                    }
                  }
                  }

                   

                  Thank you

                  Regard

                  John