Skip to main content
Inspiring
May 13, 2014
Answered

Create 'Table Cell Style' by script

Hi,

I want to check Table cell style was created in indesign? If not created I have to create the cell style name with dummy propeties as like 'TBL_COLH' 'TBL_BODY' (This is cell style name).

1. If the 'TBL_COLH' & 'TBL_BODY' this cell style appeared in Indesign, give me alert 'The cell style already presented in Indesign.

2. If the 'TBL_COLH' & 'TBL_BODY' this cell style not appeared in Indesign, I have to create cell style with dummy properites.

Is this possible by script?

by

Hasvi

Chinnadk
ChinnadkCorrect answer
Legend
May 13, 2014

Hi Hasvi,

Yes, possible. Here it is.

var doc = app.activeDocument;

var array = ["TBL_COLH", "TBL_BODY"];

for(var i=0;i<array.length;i++)

{

    try{

        doc.cellStyles.add({name:array});

        }

    catch(e)

    {

                alert("'" + array + "'" + "already exists in the document.")

        }

    }

Regards,

Chinna

3 replies

Chinnadk
ChinnadkCorrect answer
Legend
May 13, 2014

Hi Hasvi,

Yes, possible. Here it is.

var doc = app.activeDocument;

var array = ["TBL_COLH", "TBL_BODY"];

for(var i=0;i<array.length;i++)

{

    try{

        doc.cellStyles.add({name:array});

        }

    catch(e)

    {

                alert("'" + array + "'" + "already exists in the document.")

        }

    }

Regards,

Chinna

Translate
hasviAuthor
Inspiring
May 13, 2014

Hi Chinna,

Thanks a lot for your wonderful work.

by

hasvi

Translate