5 Replies Latest reply on Dec 26, 2011 2:20 PM by DKomjati

    How can I select top number in each cell in the row? Then copy, delete, paste, change font weight?

    DKomjati

      I have over 100 tables, each with about 40 individual cells that need to be revised. In each cell there are 2 numbers stacked. The top number is bold, the bottom light. My client wants these figures transposed, with the new top number also being bold and the new bottom number also being light. As you can see this will be very time consuming and tedious to do.

       

      When I try to select the top number, the 2nd number underneath is selected as well. Is there a way to select just the top numbers across the cells, copy, and paste them underneath the bottom numbers and then change the font weight on both?

       

      I have inserted two charts as examples. The first one "Original" and the second one "Clients Edits" to help illustrate my problem. Please keep in mind that I know little about writing scripts. I can open AppleScript Editor and that's about it. I'm working on this in CS3. Please help me.

       

      OriginalHeader 2Header 3Header 4

      100

      200

      200

      400

      400

      800

      800

      1200





















      Clients Edits
      Header 2Header 3Header 4

      200

      100

      400

      200

      800

      400

      1200

      800





        • 1. Re: How can I select top number in each cell in the row? Then copy, delete, paste, change font weight?
          [Jongware] Most Valuable Participant

          So these numbers are not in separate rows, but are separated by a hard return instead? (That would explain you get them *both* selected when you select the cell.)

          1 person found this helpful
          • 2. Re: How can I select top number in each cell in the row? Then copy, delete, paste, change font weight?
            [Jongware] Most Valuable Participant

            AppleScript? Nah Use JavaScript! Start the ExtendScript Toolkit editor (it should be in your Applications -> Utilities -> Adobe Utilities folder; else use Spotlight to locate it) and copy the script below into it. Save as "SwitchLinesInTablesAround.jsx" into your User Scripts folder (I'm not going to explain how to get there, there are loads of posts about that elsewhere). When saved in the correct location you will see it pop up in InDesign's Scripts Panel. Now you can do one of these:

             

            1. Put the text cursor inside any table and double-click the script. It will process just this one table.

            2. Put the text cursor inside a threaded story -- but not inside a table -- and double-click the script. It will process all tables in the story.

             

            Be careful! If you first try (1) and are happy with the result, clicking outside the table and doing (2) you will be reverting the effect on that first table! Try it out on a copy of your document first!

             

            (Assuming the script works okay, it would theoretically be safe to run it twice on the same table and get the original back. In practice, however, I'd not vouch for that.)

             

             

            //DESCRIPTION:Switch some lines in tables around -- Use With Care
            // A Jongware Script 26-Dec-2011
            
            currTable = null;
            if (app.selection.length == 1)
            {
              currTable = app.selection[0];
              if (currTable.hasOwnProperty ("baseline"))
                currTable = currTable.parent;
              if (currTable instanceof Cell)
                currTable = currTable.parent;
              if (currTable instanceof Row)
                currTable = currTable.parent;
              if (currTable instanceof Column)
                currTable = currTable.parent;
              if (!(currTable instanceof Table))
                currTable = null;
            }
            
            
            if (currTable != null)
              processOneTable (currTable);
            else
            {
              if (app.selection.length == 1 && app.selection[0].hasOwnProperty ("baseline"))
              {
                st = app.selection[0].parentStory;
                for (i=0; i<st.tables.length; i++)
                  processOneTable (st.tables[i]);
              } else
                alert ("Please click inside a story to process all tables, or inside a table to process just this one");
            }
            
            
            function processOneTable (table)
            {
              var row,cell;
              
              // process each row, skipping the first one
              for (row=1; row<table.rows.length; row++)
              {
                // process each cell
                for (cell=0; cell<table.rows[row].cells.length; cell++)
                {
                  // skip ones with more or less than 2 paragraphs
                  if (table.rows[row].cells[cell].paragraphs.length != 2)
                    continue;
                  // add a hard return at the end of the cell (we need that)
                  table.rows[row].cells[cell].texts[0].insertionPoints[-1].contents = '\r';
                  // move 2nd paragraph before 1st one
                  table.rows[row].cells[cell].paragraphs[1].move (LocationOptions.AT_BEGINNING, table.rows[row].cells[cell]);
                  // remove finale paragraph return (safely)
                  if (table.rows[row].cells[cell].characters[-1].contents == '\r')
                    table.rows[row].cells[cell].characters[-1].contents = '';
                  // apply Bold to 1st paragraph
                  table.rows[row].cells[cell].paragraphs[0].fontStyle = "Bold";
                  // apply Regular to 2nd paragraph
                  table.rows[row].cells[cell].paragraphs[1].fontStyle = "Regular";
                }
              }
            }
            
            1 person found this helpful
            • 3. Re: How can I select top number in each cell in the row? Then copy, delete, paste, change font weight?
              DKomjati Level 1

              Wow, this is exactly what I need and written for my beginners level of understanding! I was able to do all that you instructed but got a font error when I applied the Script. This is my fault because in order to simplfiy my story I referred to the fonts as Bold and Regular.

               

              The actual font names are: UniversLTStd-BoldCn.otf AND UniversLTStd-Cn.otf. InDesign refers to them as: Univers LT Std 67 Bold Condensed AND Univers LT Std 57 Condensed. I tried to switch these font names with Bold and Regular but that didn't fix my problem. Can you fix it for me?

               

              Thank you so much for all the time, work and patience that you have put into doing this to help me!!

              • 4. Re: How can I select top number in each cell in the row? Then copy, delete, paste, change font weight?
                [Jongware] Most Valuable Participant

                You're welcome! (Don't forget to press the button that says "Answered" ).

                 

                The font style problem is a well-known one, as you can only set the style of a font if that actually exists. To fix it, change the bottom lines

                 

                      table.rows[row].cells[cell].paragraphs[0].fontStyle = "Bold";

                      // apply Regular to 2nd paragraph

                      table.rows[row].cells[cell].paragraphs[1].fontStyle = "Regular";

                 

                to

                 

                      table.rows[row].cells[cell].paragraphs[0].appliedFont = "Univers LT Std\t67 Bold Condensed";

                      // apply Regular to 2nd paragraph

                      table.rows[row].cells[cell].paragraphs[1].appliedFont = "Univers LT Std\t57 Condensed";

                 

                (From the top of my head; the idea is, first you give the font family name, then a tab -- "\t" in Javascript --, then the font style.)

                • 5. Re: How can I select top number in each cell in the row? Then copy, delete, paste, change font weight?
                  DKomjati Level 1

                  You are a Rock Star!!!! Thank you so much for your help and quick response!!! You saved the day for me