• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Merging of table cells using scripts in InDesign

New Here ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

4.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 06, 2017 Jun 06, 2017

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.

Votes

Translate

Translate
Enthusiast ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

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();

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

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.

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

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/_en_04.png

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 05, 2018 Apr 05, 2018

Copy link to clipboard

Copied

Hey!

Sorry to resurrect this topic, but I am trying to use the script to merge Vertical, and when I try to merge the rows of column 10 with 11 it does not work.

Anybody has fixed this issue? - I guess it's some bug in the code but I can not find it...

Here are some tests.

For reference I am using a 21x3 col table and merging 2 rows.

C2-C21 - OK

C3-C21 - OK

C4-C21 - NO

............

C10-C21 - NO

C11-C21 - OK

Any JS masters around?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 05, 2018 Apr 05, 2018

Copy link to clipboard

Copied

Marc's script does that to me from time to time. I find if I make a smaller selection, that will work, so it may mean running the script a couple of times.

Dirk becker also has a script that works as a startup script but serves a similar purpose: Scripts for InDesign Tables

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 05, 2018 Apr 05, 2018

Copy link to clipboard

Copied

LATEST

Thanks Colin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines