Skip to main content
September 15, 2011
Question

How to adjust a table imported from Word to InDesign

  • September 15, 2011
  • 1 reply
  • 852 views

Hi all,

I am new to InDesign scripting. The problem I have is that I have hundreds of Word 2003 files which I need to import into InDesign CS5. The basics are under control excepting the tables. They import OK but then I need to change the cell padding, the style and the alignment of each table. There are lots per file.

I found a script "TableStyle.js" which adjusts the cell padding for all tables in an InDesign file (extract from the file below). What I don't know is how to change the entire table (or perhaps it is the enclosing paragraph) to Normal style and centred alignment.

Can anybody help

// Processing of tables

function myTableMaker() {

      try{var myTablesCount = mySelect.tables.length;}

      catch(err){var myTablesCount = 1;}

      for (myCounter = 0; myCounter < myTablesCount; myCounter++) {

            try{

                  var myTable = mySelect.tables.item(myCounter);

            }

            catch(err){

                  var myTable = mySelect;

            }

            // Setting spaces above and below

            myTable.spaceBefore = mySpaceBeforeSave + myUnits;

            myTable.spaceAfter = mySpaceAfterSave + myUnits;

// Change table justification to Centre Justified

// Change table style to Normal

This topic has been closed for replies.

1 reply

John Hawkinson
Inspiring
September 15, 2011

Hi Tony:

What I don't know is how to change the entire table (or perhaps it is the enclosing paragraph) to Normal style and centred alignment.

// Setting spaces above and below

myTable.spaceBefore = mySpaceBeforeSave + myUnits;

myTable.spaceAfter = mySpaceAfterSave + myUnits;

// Change table justification to Centre Justified

// Change table style to Normal

Assuming you in fact mean the paragraph styles of all the contents of all the cells, rather than a table style then:

myTable.cells.everyItem().texts.everyItem().appliedParagraphStyle="Normal";

I'm not quite sure what you mean by "centered alignment." Why not do that in the paragraph style? Anyhow:

myTable.cells.everyItem().texts.everyItem().justification=Justification.CENTER_JUSTIFIED;

September 19, 2011

Hi John,

Thanks for your answer. I am not talking about the content of the cells in the table.

I am talking about the entire table. When I do it manually I click the cursor to the left of the table and there is a flashing vertical bar, the full height of the table on the left edge of the table. Then when I click the centre justify button then the entire table moves to the centre of the page.

The same of the normal style - I want to apply the style to the table not the cells inside the table.

September 19, 2011

Use storyOffset to find the insertionpoint where the table is anchored. That's where you can make it centered or whatever.

myTable.storyOffset.appliedParagraphStyle = "Normal";

myTable.storyOffset.justification = Justification.CENTER_ALIGN;