2 Replies Latest reply on Aug 11, 2014 8:52 AM by Johnwhite

    Can you make a script for select cells?

    Johnwhite Level 1

      Hi everyone

       

      How can I tell the script

      no matter my selection in which cell or cells

      and what kind of select in cells

       

      I want to select that table from top (first row) to first empty row

       

      see pics:

       

      before select:

       

      select table top01.jpg

       

      selected:

       

      select table top.jpg

       

      thanks

      John

        • 1. Re: Can you make a script for select cells?
          Chinnadk Level 4

          Hi John,

           

          Try this.

           

          var doc = app.activeDocument,
              _selection = app.selection[0],
              _object = [];
          if(_selection instanceof Table)
          {
                  for(var i =0;i<_selection.rows.length;i++)
                  {
                          var con ="";
                          for(var j =0;j<_selection.rows[i].contents.length;j++)
                          {
                                  con +=_selection.rows[i].contents[j];
                              }
                          if(con != "")
                          {
                                  _object.push(_selection.rows[i]);
                                  app.select(_selection.rows[0]);
                                  app.select(_selection.rows[i], SelectionOptions.ADD_TO)
                              }
                          else
                          {
                                  break;
                              }
                      }
              }
          else
          {
                  alert("Select a table")
              }
          

           

          Regards,

          Chinna

          • 2. Re: Can you make a script for select cells?
            Johnwhite Level 1

            thank you Chinna

            perfect

             

            if add this:

             

            //=============================================================================

            if(app.selection[0].constructor.name=="Cell") 

                app.selection[0].parent.select(); 

            else if(app.selection[0].parent.constructor.name == "Cell") 

                app.selection[0].parent.parent.select(); 

            }

            //=============================================================================

             

            into it it will very perfect

             

            John