5 Replies Latest reply on May 31, 2010 8:26 AM by Peter Kahrel

    Select a table

    Xakie Level 1

      Can anybody tell to me how to select a table through scripting. InDesign CS3, Javascript




        • 1. Re: Select a table
          Anil Yadav Level 1

          Hi Xakie,


          Here is the code:




          Anil Yadav

          • 2. Re: Select a table
            Xakie Level 1

            Thanks Yadav,


            but didn't worked, getting this error:


            Am new to scripting, what's wrong here?



            • 3. Re: Select a table
              Peter Kahrel Adobe Community Professional & MVP



              If the first text frame in your document doesn't contain a table, then Anil's code doesn't work. It depends on where your table is and what state your document is in. Here are some approaches:


              1. If you have an insertion point selected in a table, do this:



              2. If you have a text frame selected which has a table in it, then do this:



              3. To find all tables in the document and select the first one (though "first" is a variable and fluid concept here):



              But do you really want to select a table? Whenever possible avoid working with selected items. To do something with a table, you could also address it as an object:


              myTable = app.selection[0].tables[0];

              myTable.cells[0].contents = "First cell";





              • 4. Re: Select a table
                Xakie Level 1

                Great! Simply superb.

                Me trying to select all tables from a document. Then applying the table styles.


                Once again thanks for the tips.


                • 5. Re: Select a table
                  Peter Kahrel Adobe Community Professional & MVP

                  You can use this one-liner for that:


                  app.activeDocument.stories.everyItem().tables.everyItem().appliedTableStyle = myTableStyle;