6 Replies Latest reply on Jun 8, 2017 2:18 AM by Laubender

    Merging of table cells using scripts in InDesign

    revathiv80720177 Level 1

      Hi,

       

      I have to merge cells of table using script. I have a table as shown below,


             

      ROD DIAMETER

      ROD DIAMETER TOLERANCE 1

      ROD DIAMETER TOLERANCE 2

      HOUSING DIAMETER

      HOUSING DIAMETER TOLERANCE 1

      HOUSING DIAMETER TOLERANCE 2

      1.750

      +.000

      -.003

      2.174

      +.004

      +.000

      2.500

      +.000

      -.004

      3.116

      +.005

      +.000

      5.000

      +.000

      -.004

      5.616

      +.005

      +.000

       


      Now, I have to merge cells as shown below,

          

      ROD DIAMETER

      HOUSING DIAMETER

      HOUSING DIAMETER TOLERANCE 1

      HOUSING DIAMETER TOLERANCE 2

      1.75     '+.000

                 '-.003

      2.174

      +.004

      +.000

      2.500   '+.000

                 '-.004

      3.116

      +.005

      +.000

      5.000   '+.000

                  '-.004

      5.616

      +.005

      +.000


      How can I merge cells using scripts. Please do guide me!

       

      Regards,

      Revathi

        • 1. Re: Merging of table cells using scripts in InDesign
          Liphou Level 1

          Bonjour,

           

          Ceci peux vous guidez,

           

          Ex :

          var ligne04 = "Test: ";
          
          if(app.documents.length != 0){
                  if(app.selection.length != 0 && app.selection[0].constructor.name == 'Table'){ 
                          
                          var nomTableau = app.selection[0];
                          
                                  nomTableau.rows[0].cells.item(0).merge(nomTableau.rows[0].cells.item(1));
                                  nomTableau.rows[0].cells[0].texts[0].insertionPoints[0].contents = ligne04;    
                                          
                          exit();            
          
                      }
                  else{
                              alert("Selection un tableau");
                              exit();
                          }
                  }
              else{
                  alert("Ouvrait un document et Mettre son cuseur dans le points de départ");
                  exit();
          
          }
          
          1 person found this helpful
          • 2. Re: Merging of table cells using scripts in InDesign
            Colin Flashman Adobe Community Professional

            There is a script from Indiscripts that is exactly for this purpose:

             

            Indiscripts :: Improve the Way you Merge Cells in InDesign

             

            The script works most of the time but I have noticed from time to time that despite selecting the cells and running the script, nothing happens, but if I select fewer cells, then the script works again. Bizarre.

            • 3. Re: Merging of table cells using scripts in InDesign
              revathiv80720177 Level 1

              Hi  Colin,

               

              Thanks for your response.I have my cells as ,

               

              1.750+.000-.003
              2.500+.000-.004
              5.000+.000-.004

              Using the script I was able to merge my cells as ,
                 

              1.750

              +.000 -.003

              2.500

              +.000 -.004

              5.000

              +.000 -.004

               

              I tried to merge it as,

                

              1.750

              +.000

              -.003

              2.500

              +.000

              -.004

              5.000

              +.000

              -.004

               

              I tried to change the row values to columns but the merging of cells remain the same. Please do guide me.

               

              Regards,

              Revathi

              • 4. Re: Merging of table cells using scripts in InDesign
                Laubender Adobe Community Professional & MVP

                Hi Revathi,

                if "the script" is the one written by Marc Autret—SmartCellMerge.js—you can change the separator to the one you like to see. I guess it'll be "End of Paragraph" {EOP} .

                 

                Or use any other sequence of characters.

                Marc defined three that you can insert with buttons:
                "Tabulator", "End of Paragraph" and "End of Line".

                 

                To get to that dialog where you can define this, run the script without selecting anything.

                 

                Marc Autret is describing this in detail.

                Indiscripts :: Improve the Way you Merge Cells in InDesign

                http://www.indiscripts.com/blog/public/data/improve-the-way-you-merge-cells-in-indesign/_e n_04.png

                 

                Regards,
                Uwe

                • 5. Re: Merging of table cells using scripts in InDesign
                  revathiv80720177 Level 1

                  Hi Uwe,

                   

                  Thanks for your guidance.I got it.

                  Now I have cells as

                         

                  ITEM_NO

                  ID

                  OD

                  Ht

                  GROOVE WIDTH

                  GROOVE WIDTH TOLERANCE 1

                  GROOVE WIDTH TOLERANCE 2

                  BRS-17502

                  1.750

                  2.174

                  0.166

                  0.166

                  +.010

                  +.000

                  BRS-25003

                  2.500

                  3.116

                  0.247

                  0.247

                  +.010

                  +.000

                  BRS-50003

                  5.000

                  5.616

                  0.247

                  0.247

                  +.010

                  +.000

                  I have to merge it as:

                   

                   

                  ITEM_NO

                  ID

                  OD

                  Ht

                  GROOVE WIDTH

                  BRS-17502

                  1.750

                  2.174

                  0.166

                  0.16      +.010

                               +.000

                  BRS-25003

                  2.500

                  3.116

                  0.247

                  0.247    +.010

                                +.000

                  BRS-50003

                  5.000

                  5.616

                  0.247

                  0.247    +.010

                               +.000

                  How shall I get it?Please do guide.

                   

                  Regards,

                  Revathi V

                  • 6. Re: Merging of table cells using scripts in InDesign
                    Laubender Adobe Community Professional & MVP

                    Hi Revathi,

                    I guess you need a tab between 0.16 and the +.010 and a tab before +.000 as well.

                    That means you need an extra step before merging the value cells of GROOVE WIDTH and GROOVE WIDTH TOLERANCE.

                     

                    You could select all value cells of GROOVE WIDTH and run a Find/Replace GREP on the selected cells:

                     

                    Something like that:

                     

                    Find:

                    ^(.+)$

                     

                    Replace:

                    \t$0

                     

                     

                    And then do the merge of GROOVE WIDTH and GROOVE WIDTH TOLERANCE with no sepaparation character.

                     

                    1. After GREP Find/Replace:

                     

                    1-AfterGREP-Find-Replace.png

                     

                    2. Changing preferences with Marc's SmartCellMerge script.
                    No separation character applied.

                    2-MergeDefaults-NoCharacter.png

                     

                    3. After the merge:

                     

                    3-AfterMerge.png

                     

                    Regards,

                    Uwe