Table and cell Style

Hi all

Greetings...

The script below works perfectly in indesign CS3 to apply table and cell style. But in indesign CS4 shows runtime error. Kindly help me on this...

var myTable = app.activeDocument.stories.everyItem().tables; 

for (var n=0; n < myTable.length; n++)
{ 
     myTable[n].appliedTableStyle = "Table Style 1"; 
     myTable[n].cells.everyItem().appliedCellStyle = app.activeDocument.cellStyles.item("[None]");
     myTable[n].cells.everyItem().clearCellStyleOverrides (true); 

     alert(myTable[n].rows.length);

    for (var a = 1; a < myTable[n].rows.length - 2; ++a)
     {
           myTable[n].rows[a].cells.everyItem().appliedCellStyle = "T body";
           alert(a);
     }
  
    myTable[n].rows[0].cells.everyItem().appliedCellStyle = "T col hd";//First Row 
     myTable[n].rows[-1].cells.everyItem().appliedCellStyle = "T body bot";//Last Row

}

Thank you

Knockaert

Hi Karthik,

Please try the JS Code below and come back.

var myTable = app.activeDocument.stories.everyItem().tables;
 for (var n=0; n < myTable.length; n++){
//~      myTable[n].appliedTableStyle = "Table Style 1";
//~      myTable[n].cells.everyItem().appliedCellStyle = app.activeDocument.cellStyles.item("[None]");
//~      myTable[n].cells.everyItem().clearCellStyleOverrides (true); 

// Please check the table cell styles name is correct or not?
    var myActiveTable = myTable[n];
    myActiveTable.rows.itemByRange(0,-2).cells.everyItem().appliedCellStyle = "TB";
    myActiveTable.rows[0].cells.everyItem().appliedCellStyle = "TCH";//First Row
   myActiveTable.rows.itemByRange(-2,-1).cells.everyItem().appliedCellStyle = "TBB";//Last Row
    }

the output of code js above looks like this snapshot.

THX

csm_phil

Tags: InDesign

Similar Questions

  • Tame the table and cell styles

    I find table styles and cell styles to be quite a nightmare in InDesign - in other words, as long as the paragraph style is included in the definition of the cell style. The only way I could get a table without substitution involves the steps as much as it is not effective:

    1) click an empty paragraph.

    (2) apply the paragraph style.

    (3) type the text that will come eventually in a table cell. (All my paintings are a cell, a column tables).

    (4) select the text without selecting the symbol of paragraph at the end.

    (5) choose table > convert text to table.

    I would be very happy if anyone knows of a script that can do these steps and can put me out of my misery.

    (Or maybe is there a way to avoid cell style replacements that I did not discover. (There was a discussion on this problem to http://forums.adobe.com/message/2043634#2043634, but none of the suggestions got rid of substitutions of paragraph style cell.)

    Hi jay

    You should check the character styles. If paragraph styles will not be on the trip, I found that it is because it applies a character style. Some people use styles to the paragraphs format characters. (?!)

    RB

  • How can I export table and cell styles to use in another InDesign document?

    I've been looking for... and looking but cannot find out how to export table styles in InDesign CC. If there is an option of the control panel load table styles, it goes without saying that there should be an export. Any help would be appreciated, thanks.

    Frank.GRG wrote:

    If there is an option of the control panel load table styles, it goes without saying that there should be an export.

    I understand your logic, but you think too much of it. Charge function Styles opposes the need for an export feature. When you call the function of load, you simply select the source document, then the individual styles that exist already in it. They need not be implemented beforehand.

  • AppleScript to apply styles of table and cell in IDCS4

    I have an Applescript script to format all the tables in a document as I want.  It is adapted from a previous version that did not use styles, that works perfectly.  This script creates styles if they are not present and this bit works fine, but when it starts to try to apply them to the tables, it falls.

    tell application "Adobe InDesign CS4"
         tell active document
              set BlackColor to color "Black"
              set SolidStroke to stroke style "Solid"
         end tell
         tell active document
              try
                   set myTablePara to paragraph style "4.2 Table text"
              on error
                   set myTablePara to make paragraph style with properties {name:"4.2 Table text", applied font:"Helvetica Neue", font style:"Regular", point size:"8.5", leading:"10"}
              end try
              try
                   set myBasicCell to cell style "Basic cell"
              on error
                   set myBasicCell to make cell style with properties ¬
                        ¬
                             {name:¬
                                  "Basic cell", bottom edge stroke weight:0 ¬
                                  , bottom edge stroke color:BlackColor ¬
                                  , bottom edge stroke type:SolidStroke ¬
                                  , right edge stroke weight:0 ¬
                                  , right edge stroke color:BlackColor ¬
                                  , right edge stroke type:SolidStroke ¬
                                  , top edge stroke weight:0 ¬
                                  , top edge stroke color:BlackColor ¬
                                  , top edge stroke type:SolidStroke ¬
                                  , left edge stroke weight:0 ¬
                                  , left edge stroke color:BlackColor ¬
                                  , left edge stroke type:SolidStroke ¬
                                  , left inset:¬
                                  "0p4", right inset:¬
                                  "0p4", top inset:¬
                                  "0p4", bottom inset:¬
                                  "0p4", vertical justification:top align ¬
                                  , applied paragraph style:myTablePara}
              end try
              try
                   set myHeader to cell style "Header"
              on error
                   set myHeader to make cell style with properties ¬
                        {name:¬
                             "Header", based on:myBasicCell ¬
                             , bottom edge stroke weight:¬
                             "0.5pt", top edge stroke weight:"0.75pt", vertical justification:bottom align ¬
                             }
              end try
              try
                   set myFooter to cell style "Final Row Cell"
              on error
                   set myFooter to make cell style with properties ¬
                        {name:¬
                             "Final Row Cell", based on:myBasicCell ¬
                             , bottom edge stroke weight:¬
                             "0.75pt"} ¬
                             
              end try
              try
                   set myLeftCol to cell style "First Column Cell"
              on error
                   set myLeftCol to make cell style with properties ¬
                        {name:"First Column Cell", based on:myBasicCell, left inset:0}
              end try
              try
                   set myLeftHeader to cell style "First Row, First Column Cell"
              on error
                   set myLeftHeader to make cell style with properties ¬
                        {name:"First Row, First Column Cell", based on:myHeader, left inset:0}
              end try
              try
                   set myLeftFooter to cell style "First Column Last Row Cell"
              on error
                   set myLeftFooter to make cell style with properties ¬
                        {name:"First Column Last Row Cell", based on:myFooter, left inset:0}
              end try
              
              try
                   set myTableStyle to table style "Horizon"
              on error
                   set myTableStyle to make table style with properties {name:¬
                        "Horizon", body region cell style:¬
                        myBasicCell, header region cell style:¬
                        myHeader, footer region cell style:¬
                        myFooter, left column region cell style:myLeftCol}
              end try
         end tell
         set allTables to every table of every story of active document
         repeat with i from 1 to count of allTables
              set myTable to item i of allTables
              set table style of myTable to myTableStyle
              set properties of cells of myTable to ¬
                   {cell style:myBasicCell}
              set properties of cells of first column of myTable to ¬
                   {cell style:myLeftCol}
              set properties of cells of first row of myTable to ¬
                   {cell style:myHeader}
              set properties of cells of last row of myTable to ¬
                   {cell style:myFooter}
              set properties of first cell of first row of myTable to ¬
                   {cell style:myLeftHeader}
              set properties of first cell of last row of myTable to ¬
                   {cell style:myLeftFooter}
              clear cell style overrides
              clear table style overrides
         end repeat
    end tell
    

    When it is to 'set style table of myTable to myTableStyle' it is said ' impossible to define style table id of the table to text frame id page id 220 190 of spread id 185 [the first table] document \"Untitled-1\" table style id 264 [style newly generated] document \"Untitled-1\" 224 "  But I can't tell why.  Can anyone help?

    Table and cell styles are objects. When you want to apply, you must set the appropriate properties that are 'applied the style of table"and"cell style ". So: «the game applied style table myTable...» »

    But in terms of results, you'll be probably happier using the commands ' apply the style of table cell / ' instead, which allows you to clear the replacements.

    --

    Shane Stanley [email protected]>

    AppleScript Pro Sessions http://scriptingmatters.com/aspro>

  • Centering the table and cell borders.

    Hello, everyone:

    I am creating a tabular presentation and wish to have my main table (containing another table in some of its cells) is centered in the window of my browser so that as the viewer resizes the window web page design remains in the Middle both in horizontal and vertical plans. I found a command in Dreamweaver that allows me to Center a table on the horizontal plane, but nothing that allows me the same thing on the vertical plane. How can this be accomplished? I prefer to stay away from CSS that I'm still not familiar and sufficiently comfortable around her. I prefer to stay with a simple table layout.

    I also try to set fixed sizes for my table cells, but have not found a way to do it. I managed to create transparent GIF images to use as placeholders but (1) this seems to be too much work for something that probably can be accomplished in a much easier way and (2) the cells are not confined to the size of the GIFs and eventually larger than GIF images.

    Any suggestions will be appreciated.

    Thank you in advance,

    Joseph Chamberlain

    James:

    I thank you for your help and you have my apologies for this late reply.

    I looked at the link you provided and it has the answer to my question. Thank you once again. I wish just that there is a simpler and intuitive to do.

    Best regards

    Joseph Chamberlain

  • Table and cell borders

    I use CS4. I created a table style in my stylesheet that calls for an orange 2 px wide border. The border only described the entire table, but not individual cells. Anyone know how I can fix this in the stylesheet?
    The URL is http://www.virginiacpac.org/pages/conference.html
    Thank you

    Hello

    Try this:

    {.table_border}
    border-collapse: collapse;
    }
    .table_border td {}
    border: 2px solid #E2832F;
    padding: 2px;
    }

    Take care
    Tim

    "dlipscombe" wrote in message
    News:giekco$BQJ$1@forums. Macromedia.com...
    > I'm using CS4. I set up a table style in my stylesheet that calls for a 2
    > px
    > orange wide border. The border only outlines the entire table but not the
    > individual cells. Anyone know how I can fix this in the stylesheet?
    > The URL is http://www.virginiacpac.org/pages/conference.html
    > Thank you,
    >
    > .table_border {}
    > border: 2px solid #E2832F;
    > padding: 2px;
    > }
    >

  • tables and cell phone screen

    Does anyone know an html tag or css that can load another page, if the browser detects Web site is loaded on a phone screen?  or any other solution to put a couple of things in tables maybe so they load correctly on a mobile phone?  I have some pages I'm working very well and they load fine on my laptop and my MS Surface, but watching them in dreamweaver using the resolution feature, the tables don't look just to the right, so I would like to know if there is an alternative out there that might work and always show things in a table properly.

    Thank you.

    Use div tags 3 or more floating that breaks over a width of single column on smaller devices.

    CSS MEDIA QUERY

    =================

    @media only screen and (min-width: 769px) {}

    . Row {overflow: hidden}

    / * clear floats * /.

    . Row: after {}

    Clear: left;

    Display: block;

    content: '.';

    visibility: hidden

    }

    . Box {}

    Width: 33.33%;  / * 3 rows * /.

    float: left;

    }

    }

    HTML CODE:

    ================

    It's 1 box

    It is area 2

    It's box 3

    It's 1 box

    It is area 2

    It's box 3

    Nancy O.

  • JSON in table and then style CSS with data

    Hello

    I am desperate to solve this little problem of creating a chart bar and I think my coding ability is let me down. I have a single .js file that contains a JSON object as follows:

    var = [] bars

    {"type": "data1", "total": 5},

    {"type": "data2", "total": 10},

    {'type': 'data3', 'total': 30}

    ];

    I added this file to EA scripts. Now, I want to extract all of the 'total' data in a table. The following would work?

    var total = new Array();

    for (i = 0, I < 3, i ++) {}

    totals [i] = .total bars [i];

    }

    Once I have my table filled with the data I want to use this data to determine the heights of certain elements. How can I insert a variable in the CSS code? For example:

    var elementHeight = 30;

    SYM. $("element") .css ({"transform": "scaleY (elementHeight)"});

    I can get this second line of work with just a number, but I do not know how to pass a variable. Any help would be a lifesaver of a desperate man.

    Thank you very much

    Barry

    You're not not making reference to the variable in the example you posted, but rather to define the scaleY transformation as "elementHeight.

    SYM. $("element") .css ({'transform': ' scaleY ("+ elementHeight +" "") "" "});

  • I am self-taught and use since CS4 - archaic, tables, etc. for years smoothly other than those associated with tables and cells.

    I can not Dreamweaver to find the .jpgs I put on the remote server.  I can bring to the top of the page on the Internet, but not jpg - three on the page.

    I can't get Dreamweaver to keep the remote path.  I don't have local copies of my existing site on Dreamweaver.  The page works fine, links, etc.  I'm trying to add a page, not a site, but when the page is in place the jpgs will not appear.  My only choice in Dreamweaver are refferences "site" and the document.  I put the remote path in a zillion times in many ways.  But no connection.

    I created a new page and it is the only one that I'm trying to get the jpg images to be called from.  The remote page is: www.columbianexpositiontickets.com/All Pages/ferrispage/mainferris.htm ticket sales.  There are three JPGs on the page and everything just, I don't know how to change the situation where the jpg files will appear.

    I have three JPEG images in the folder 'ferrispage' and even a 'pictures' folder in the same folder.

    CS4, Win7.

    I do not know how to change the remote possibility, just "site" and "pertinent" are presented.  I sometimes get a "530 login incorrect.

    Drives me crazy, as everyone and suggestions would be appreciated.

    Thank you, Hal Hill

    Well, let's start with this unfortunate image in your source code:

    "height FTP://halhill:***@74.91.214.252/columbianexpositiontickets.com/All%20Ticket%20Sales%20page s/ferrispage/frontlargecert.jpg" ="388" border ="0" width = "500" > ".

    Immediately, I know what the problem with this link.  The question is do you have?

    TIP #1: %20 is spaces.  Use no spaces or special characters in web folder or file names.  She creates problems on the server.

    TIP #2: Remove all this:

    FTP://halhill:***@74.91.214.252/


    and replace with this:

    http://

    It is a problem solved.

    See if you can solve yourself the other paths of bad image.

    Nancy O.

  • How can I fix the join table dotted outline style?

    I kept super organized when setting up my styles to table this time. I put as much as possible in the configuration of the tracked table of cell styles for some of the columns and some lines (like subdivisions). The problem with cell styles, is that you cannot set cells of running styles, only around them. So if there is a setting to do at the macro level, I would be really happy. I always get problems with formatting applied when I apply a too large number of styles or substitutions, that's what I'm trying to avoid.

    Here's the problem: table styles are still process my shots at the level of the individual cell. I use dotted in the columns, but there is no seal between the rows. They line you up at the top and at the bottom of each cell. See gray lines in this example (blue dots are bullets, not shots):

    Screen shot 2012-10-02 at 2.28.38 PM.png

    But when I replace the column and redo the outline in the outline palette, they look as expected. Compare the cells highlighted (black) to the existing table style (lines white gray and light):

    Screen shot 2012-10-02 at 2.32.05 PM.png

    Is there a setting somewhere that I'm missing? Any suggestions apart from the hand control?

    Note: I'm in CS6 on Mac 10.6, where it is important.

    In fact, I need cell styles. This is what distinguishes my font, spacing and GREP styles.

    I found the solution today. In the style of table or the table setting, I needed the "race drawing of mark" 'column Strokes in Front. Even if it has been previously set to 'Best joins' and I had no hits for lines or for table borders, was not simply giving priority to my columns dotted.

    Thanks for your reply though!

  • Help with a script to search for text in a table cell and apply the cell style

    Hello

    I build the script which Jongware wrote in his post here http://indesignsecrets.com/tackling-tables-through-scripting.php - I am trying to create a variable in which I can add a number of different parts of the text, in this case it's different parts of the United Kingdom i.e. 'London', 'East', 'Scotland' etc. I just need the script to apply the cell Style - 'District Cell' - to any cell that contains text in the variable. Here's the script, if anyone can help I would be grateful.

    function checkWhichTable()
    {
    // ensure the user made a selection
    if (app.selection.length != 1)
    return null;
    var currentTable = app.selection[0];
    if (currentTable.hasOwnProperty("baseline"))
    {
    currentTable = app.selection[0].parent;
    }
    while (currentTable instanceof Cell || currentTable instanceof Row || currentTable instanceof Column)
    currentTable = currentTable.parent;
    if (!(currentTable instanceof Table))
    {
    // No table selected
    return null;
    }
    return currentTable;
    }
    app.doScript(checkUserSelection, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Process Table");
    
    
    function checkUserSelection ()
    {
    var a_table = checkWhichTable();
    if (a_table == null)
    {
    if (confirm("No table selected. Do you want to process *all* tables?") == false)
    return;
    allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
    for (aTable=0; aTable<allTables.length; aTable++)
    {
    processTable (allTables[aTable]);
    }
    } else
    {
    processTable (a_table);
    }
    }
    function processTable(table)
    {
    // do something here!
    
    
    //Find Text in Cell and apply Cell Style
    var textInCell=['London', 'Scotland', 'South West'];
    for (i=0; i<table.cells.length; i++)
    {
    if (table.cells[i].texts[0].contents==textInCell)
    table.cells[i].appliedCellStyle = "District Cell";
    }
    
    
    
    
    }
    

    Hello

    Change this feature:

    function processTable(table)
    {
    //Find Text (exactly as it is) in Cell and apply Cell Style
    var
      textInCell=['London', 'Scotland', 'South West'],
      mFound, cFound;
    
    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat = "^(" + cities.join("|") + ")$";
    mFound = table.findGrep();
    while( cFound = mFound.pop() )
      cFound.parent.appliedCellStyle = "District Cell";
    }
    

    Jarek

  • Help with a script that detects the content in a cell and apply the cell style to line

    Hello


    I am trying to add an article to my table formatting script that is a cell with the word 'Budget' (but this can be written as ' Budget:' or ' Budget: (E) "- but without the speech marks) and apply the cell Style - SponsorCells - to all the cells of the whole line. I currently have on what it will, but it does not work:


    function checkWhichTable()
    {
    // ensure the user made a selection
    if (app.selection.length != 1)
    return null;
    var currentTable = app.selection[0];
    if (currentTable.hasOwnProperty("baseline"))
    {
    currentTable = app.selection[0].parent;
    }
    while (currentTable instanceof Cell || currentTable instanceof Row || currentTable instanceof Column)
    currentTable = currentTable.parent;
    if (!(currentTable instanceof Table))
    {
    // No table selected
    return null;
    }
    return currentTable;
    }
    app.doScript(checkUserSelection, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Process Table");
    
    
    function checkUserSelection ()
    {
    var a_table = checkWhichTable();
    if (a_table == null)
    {
    if (confirm("No table selected. Do you want to process *all* tables?") == false)
    return;
    allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
    for (aTable=0; aTable<allTables.length; aTable++)
    {
    processTable (allTables[aTable]);
    }
    } else
    {
    processTable (a_table);
    }
    }
    function processTable(table)
    {
    // do something here!
    
    
    //Set 1st Row Height
    table.rows[0].height = "30mm";
    
    
    //Find Text in Cell and apply Cell Style to Row 
    var  
      myCellText=['Budget', 'Budget:', 'Budget: (E)'];  
     var myRegEx = new RegExp("^("+myCellText.join("|")+")$");
      for (i=0; i<table.cells.length; i++)
      {
        if (table.cells[i].texts[0].contents.match(myRegEx))
          table.cell[i].appliedCellStyle = "SponsorCells";
      }
    
    
    //end - do something here!
    }  
    


    I can get the script to apply the cell style to "SponsorCells" for each cell that contain the word 'Budget' etc, but I need cell ever on this line to have the cell style applied. I tried to re-write line 56 which applies the style to a cell, but I can't seem to make it work. Any help would be great.


    Separate on this issue, I would like to have a line of code similar to the 46 line, which sets the 1st height of lines, but I would like to say "If a cell has 'A cell Style' and then applies the value height 10 mm". If someone could result as a help of bonuses, things would be great double.


    Thanks in advance!

    But that could be painfully slow. To speed things up, follow these steps:

    var cells = table.cells.everyItem().getElements();
    for (var i=0; i
    

    It is faster, because it creates an array of cells with a call to table.cells, which is several times faster than calling table.cells. And before assigning to line 12mm height is useful to check if it is already 12 mm. checking things in InDesign and do things only when it is necessary is much more effective than simply doing things even if they are not necessary.

  • With the last update, I am unable to merge cells in a table and Ive tried Split and Live view.

    With the last update, I am unable to merge cells in a table and Ive tried Split and viewing live, all the tutorial and manuals say to do in Design view, which is no longer available.  How to merge cells in a table now?

    To get the fashion Design back in a checkerboard to fluid...

    Close all other files, open the fluid grid css and add the X below:

    /*

    Properties Grid Dreamweaver fluid

    ----------------------------------

    DW-num-CLO-mobile: X 4;

    DW-num-CLO-Tablet: 8;

    DW-num-OCOL-Office: 12;

    DW-gutter-percentage: 25;

    =====================================

    Then save and close the file.

    DW restart and you should have mode Design from here out on all files using this fluid grid .css file.

  • change the first line of a table to a cell style

    Hello

    I want to change the first line of a table to a cell style.

    Is this possible in javascript?

    Patrick

    Hi patrickbcm,

    Try the threshold.

    app.activeDocument.stories.everyItem().tables.everyItem().rows[0].cells.everyItem().appliedCellStyle = app.activeDocument.cellStyles.item("row1");
    

    THX,

    csm_phil

  • Create 'Table cell Style' by script

    Hello

    I want to check the style of table cell was created in indesign? If not created I need to create the style name of cell with dummy properties such as 'TBL_COLH', 'TBL_BODY' (is the cell style name).

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

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

    Is it possible by script?

    by

    Hasvi

    Hi Hasvi,

    Yes, possible. It's here.

    var doc = app.activeDocument;

    var table = ['TBL_COLH', 'TBL_BODY'];

    for (var i = 0; i)<>

    {

    try {}

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

    }

    catch (e)

    {

    Alert ("'" + array [i] + "'" + "already exists in the document.")

    }

    }

    Kind regards

    Cognet

Maybe you are looking for