12 Replies Latest reply on May 19, 2010 12:15 AM by Marijan Tompa [tomaxxi]

    finding cells by content en replace stroke & fill colour

    PascalDobbelaere

      I have generated in InDesign CS3 a catalogue with hundreds of tables.

       

      unfortunatly there was a mistake or two in building the tables. In a way I need to replace a stroke colour from a cell and also a fill colour.

       

      So my question is if there is a way in InDeisgn CS3 for automatically...

       

      • searching in a document for table cells with "text colour Black_EN" AND "fill colour Black_EN" and change that particular cell stroke colour in Black_EN
      • searching in a document for table cells with "text colour Black_EN" AND "fill colour Black" and change that particular cell fill colour in Black_EN

       

      Can someone help me with a usable script? I'm a newie to scripting so any help is usefull!

       

      thanks in advance, Pascal (form Belgium)

        • 1. Re: finding cells by content en replace stroke & fill colour
          TonKuypers Level 1

          Hi Pascal,

           

          Do you need this script for Mac or Windows?

          I might be able to assist you, when I can create the script in AppleScript...

           

          Greetings,

           

          Ton (also from Belgium)

           

          Take a look at www.publishingtools4u.com for more info and how to contact me directly.

          • 2. Re: finding cells by content en replace stroke & fill colour
            PascalDobbelaere Level 1

            Hi Ton,

             

            it's Windows I'm working with...

            • 3. Re: finding cells by content en replace stroke & fill colour
              TonKuypers Level 1

              hmmm.... I'm not so heavy on VB or JavaScript, so I'm afraid I can't help you in between my other jobs... What you need is very doable, so hopefully someone else will give you a script for your problem.

              If not, just contact me directly and I will take a look if I can assist you.

               

               

              Met vriendelijke groeten,

              Warm Regards,

               

               

               

              Ton Kuypers

              +32 (0) 477 739 530

               

              Aardbemden 11 • B-2400 • Mol • Belgium

              www.publishingtools4u.com

              • 4. Re: finding cells by content en replace stroke & fill colour
                [Jongware] Most Valuable Participant

                Here is a Javascript version that ought to work. Copy, paste into a plain text editor (Notepad, Textedit -- in plain text mode --, or Adobe's own ESTK Editor), and save as "ChangingSomeCellColorsToSomethingElse.jsx" into your User Scripts folder. Double-click to run.

                 

                I'm puzzled, though -- you do realize your text color and the cell's fill color are the same?? "Text colour Black_EN" AND "fill colour Black_EN" in the first half, "text colour Black_EN changing cell fill colour in Black_EN" in the 2nd half ...

                 

                 

                black = app.activeDocument.swatches.item("Black");
                black_en = app.activeDocument.swatches.item("Black_EN");
                app.findTextPreferences = null;
                app.findTextPreferences.fillColor = black_en;
                foundResults = app.activeDocument.findText();
                for (a=0; a<foundResults.length; a++)
                {
                 if (foundResults[a].parent instanceof Cell)
                 {
                  if (foundResults[a].parent.fillColor == black_en)
                  {
                   foundResults[a].parent.properties = {
                    topEdgeStrokeColor:black_en,
                    bottomEdgeStrokeColor:black_en,
                    leftEdgeStrokeColor:black_en,
                    rightEdgeStrokeColor:black_en };
                   continue;
                  }
                  if (foundResults[a].parent.fillColor == black)
                  {
                   foundResults[a].parent.fillColor = black_en;
                  }
                 }
                }
                

                 

                • 5. Re: finding cells by content en replace stroke & fill colour
                  PascalDobbelaere Level 1

                  Hi Jongware,

                   

                  thanks for passing me this script. I forgot to mention... the fill colour must be 50% of the colour (Black_EN), can this also be nested in de script?

                   

                  Greetz, Pascal

                  • 6. Re: finding cells by content en replace stroke & fill colour
                    [Jongware] Most Valuable Participant

                    Sure! (That takes care of my worries re: fill and text color.)

                    Add this line

                     

                    foundResults[a].parent.fillTint = 50;

                     

                    above the "continue" line, and, if you want it for the second case as well, add the same line directly below the second fillColor line.

                     

                    I noticed something else:

                     

                    1. The script searches for all text in the Black_EN color and checks if it's inside a cell. If so,

                    2a. If the fill color is Black_EN, the stroke is set to Black_EN

                    2b. BUT if the fill color is Black, it is set to Black_EN and the stroke is not changed.

                     

                    That's the order in which you presented your two-things to do; and the order in which I process them ensures each cell is checked, but ONLY ONE of these actions is actually performed. Is that still what you had in mind? Or did you mean,

                     

                    • searching in a document for table cells with "text colour Black_EN" AND "fill colour Black" and change that particular cell fill colour in Black_EN

                    followed by

                    • searching in a document for table cells with "text colour Black_EN" AND "fill colour Black_EN" and change that particular cell stroke colour in Black_EN

                     

                    (which is also perfectly doable, of course )

                     

                    Groetjes!

                    • 7. Re: finding cells by content en replace stroke & fill colour
                      PascalDobbelaere Level 1

                      I think the problem could be solved in what YOU mentioned (better explenation of what I meant):

                       

                       

                      • searching in a document for table cells with "text colour Black_EN" AND "fill colour Black" and change that particular cell fill colour in Black_EN

                      followed by

                      • searching in a document for table cells with "text colour Black_EN" AND "fill colour Black_EN" and change that particular cell stroke colour in Black_EN

                       

                       

                       

                      Because there are other regular textframes and languages I think I realy have to contentrate on that particular textcolour in a cell, in order NOT to affect other frames/cells/...

                       

                      a snapshot of my problem can be find on

                      http://www.velleman.eu/downloads/problemAC.pdf

                       

                      Hope you can help me

                      alvast bedankt

                       

                      Pascal

                      • 8. Re: finding cells by content en replace stroke & fill colour
                        [Jongware] Most Valuable Participant

                        Aaahh .. the old adage of one picture equalling a thousand words. In this case, the words are rather long, as the image is >280K.

                         

                        O-kay. You have lots of tables, possibly some with bad colors, but the text is always the correct color. How does this sound: you click inside any table, and the script checks the current text color (*). Then it sets all strokes to that color, and the fill of every cell with a 50% fill pattern. It means you can select a table, run the script, select the next, run the script, etc. until done (or utterly bored, whatever comes first).

                         

                        (*) Actually, the text color of the first character in the top left cell. I hope that's not a problem.

                         

                        The script is fairly indifferent to your selection: anywhere inside, in the text, or with a cell, row, column or even the entire table selected is no problem.

                         

                        Graag gedaan! (having them English folks choke on our Dutch gees)

                         

                         

                        table = app.selection[0];
                        if (table.hasOwnProperty("baseline"))
                         table = table.parent;
                        if (table instanceof Cell)
                         table = table.parent;
                        if (table instanceof Column)
                         table = table.parent;
                        if (table instanceof Row)
                         table = table.parent;
                        if (!(table instanceof Table))
                        {
                         alert ("Echt niet in een tabel!");
                         exit(0);
                        }
                        color = table.cells[0].characters[0].fillColor;
                        black = app.activeDocument.swatches.item("Black");
                        table.cells.everyItem().properties = {
                         topEdgeStrokeColor:color,
                         bottomEdgeStrokeColor:color,
                         leftEdgeStrokeColor:color,
                         rightEdgeStrokeColor:color };
                        for (aCell=0; aCell<table.cells.length; aCell++)
                         if (table.cells[aCell].fillTint == 50)
                          table.cells[aCell].fillColor = color;
                        
                        • 9. Re: finding cells by content en replace stroke & fill colour
                          PascalDobbelaere Level 1

                          Wonderful! It's working just fine!

                           

                          But is there also a possibility to apply the script to a whole document instead of selecting text in a table?

                           

                          there are really hundreds of tables, and 4 versions are grouped together and are flowing inline in a textframe...

                          (catalogue was generated with EasyCatalog en in that way we can keep our textflow, even when an product comes in between)

                           

                          If no possibility, no problem.

                           

                          You've already deserved your "pintje" ;-)

                           

                          Thanks again!

                           

                          Pascal

                          • 10. Re: finding cells by content en replace stroke & fill colour
                            [Jongware] Most Valuable Participant

                            How's this? (Warning: didn't really debug, I'm deep into a >750 pages book rite now & should really get something done )

                             

                             

                            s = app.selection[0].parentStory;
                            for (aTable=0; aTable<s.tables.length; aTable++)
                             processTable (s.tables[aTable]);
                             
                            function processTable (table)
                            {
                             color = table.cells[0].characters[0].fillColor;
                             black = app.activeDocument.swatches.item("Black");
                             table.cells.everyItem().properties = {
                              topEdgeStrokeColor:color,
                              bottomEdgeStrokeColor:color,
                              leftEdgeStrokeColor:color,
                              rightEdgeStrokeColor:color };
                             for (aCell=0; aCell<table.cells.length; aCell++)
                              if (table.cells[aCell].fillTint == 50)
                               table.cells[aCell].fillColor = color;
                            }
                            
                            • 11. Re: finding cells by content en replace stroke & fill colour
                              PascalDobbelaere Level 1

                              I'll check it out

                               

                              Is is possible to make the stroke colours "overprint"?

                               

                              gr.

                              • 12. Re: finding cells by content en replace stroke & fill colour
                                Marijan Tompa [tomaxxi] Level 4

                                PascalDobbelaere wrote:

                                 

                                I'll check it out

                                 

                                Is is possible to make the stroke colours "overprint"?

                                 

                                gr.

                                 

                                bottomEdgeStrokeOverprint:true,
                                leftEdgeStrokeOverprint:
                                true,
                                rightEdgeStrokeOverprint:
                                true,
                                topEdgeStrokeOverprint:
                                true

                                 

                                http://forums.adobe.com/message/2824762