Need to apply table fill color based on text content

Totally new to Indesign-scripting – but really need a solution to this:
I have a table
I want to fill the table cell with a different color based on text content.
If cell contents the text "Apple" fill color of cell should be color swatch "Red"
If cell contents the text "Banana" fill color of cell should be color swatch "Yellow"
Any help most appriciated!

Hi Franke,
Try the below code, may it will helpful:
var myDoc = app.activeDocument
//var myCell = app.activeDocument.textFrames.everyItem().tables.everyItem().cells.everyItem().getElement s()
app.findTextPreferences = app.changeTextPreferences = null
app.findTextPreferences.findWhat = "Apple"
var myFound = myDoc.findText()
for(i=0; i<myFound.length; i++)
    if(myFound[i].parent.constructor.name == "Cell")
    myFound[i].parent.fillColor = "aaa"
If the above code helps you, then please give Helpful or Correct Answers.
Because for the last 3 months only I started my Indesign Scripting Career.
With the help of Forum legends I can able to reply for simple questions.
Thanks all...
Regards
BEGINNER

Similar Messages

  • ADF Table cell color based on the value in that field

    Dear All,
    I want to create a table for our new application which contains a table used to represent the data in a chart format or matrix format,
    and each cell of the table should be filled with a colour out of three colors, based on the value belongs to which range eg:(1-8 ->green, 9-20 - yellow etc),
    I dont know how to implement this. Please help...
    Ranjith

    Check this out.
    How to highlight ADF table row based on column value?
    -Arun

  • Script to change fill color based on excel data?

    Hi.  I'm curious if there is a way to change the fill color of, say a rectangle, in Illustrator based on data in an excel spreadsheet (csv or whatever).  For example: say the data in the excel cell is 1 and that corresponds to the rectangle in Illustrator having a yellow fill...  Now say I update the data in the cell to 2 and save.  I run the script and it makes the box red.  Is that even remotely possible?  Thanks.

    Hi, yes it's possible, I used VBA on Windows
    Assuming you have an Illustrator file with 1 square, and 2 swatches named "yellow" and "red"
    this is how I set up the excel file
    type the formula in cell F2 as shown, make your color updates on cell E2
    VBA code:
    Sub recolorSquare()
        Dim iapp As New Illustrator.Application
        Dim idoc As Illustrator.Document
        Dim rect As Illustrator.PathItem
        Dim whatColor As String
        whatColor = range("F2")
        Set idoc = iapp.ActiveDocument
        Set rect = idoc.PathItems(1)
        rect.FillColor = idoc.Swatches(whatColor).Color
        Set rect = Nothing
        Set idoc = Nothing
        Set iapp = Nothing
    End Sub

  • Need to apply on the order based on customes

    Hi All
    I need to apply hold on orders which was created by particular customers.. For that I used "oe_holds_pub.apply_holds" API by passing parameter like
    v_hold_source_rec oe_holds_pvt.hold_source_rec_type
    DEFAULT oe_holds_pvt.g_miss_hold_source_rec;
    v_hold_source_rec.hold_id := v_hold_id;
    v_hold_source_rec.hold_entity_code := 'C';
    v_hold_source_rec.hold_entity_id := customer_id
    oe_holds_pub.apply_holds
    (p_api_version => 1.0,
    p_init_msg_list => fnd_api.g_true,
    p_commit => fnd_api.g_false,
    p_validation_level => fnd_api.g_valid_level_full,
    p_hold_source_rec => v_hold_source_rec,
    p_hold_existing_flg => 'Y',
    p_hold_future_flg => 'Y',
    x_return_status => v_return_status,
    x_msg_count => v_msg_count,
    x_msg_data => v_msg_data
    When I executed the program it show return_status='S' mean "success", But, when i check the Order of particular customer(IN front end) it doesn't change to 'HOLD', I need information on this API? what are the parameters we need to pass?
    Difference b/w hold_entity_code='C' and hold_entity_code='O'(is their any particular meaning for 'O' and 'C')?
    hold_entity_id: Refers for?
    Can any one send the link..........

    Hi Suresh,
    You can go to the technical settings and tick the check box Log Data Changes at the bottom of the screen.
    Hope it helps...
    Lokesh
    Pls. reward appropriate points
    Message was edited by: Lokesh Aggarwal

  • Making sidebar fill colors "scroll" with main content div

    Just when I think this newbie is getting the hang of Dreamweaver, something throws me a curve
    I have a three column fixed layout designed in Dreamweaver CS4 at the URL below. Each of the two sidebars - left and right - has a fill color. I would like those sidebar fill colors to "scroll" or "flow" down as the content of the middle, main content div expands. As it is, the fill color of the two sidebars stops when their content stops, even if the middle content continues.
    I'm guessing I'm overlooking something simple here. Can someone tell me how to accomplish this?
    Many thanks in advance.
    http://firinglinedesign.com/mathieu/

    That is really ingenious! Many thanks for the lead. For anyone else who has this issue, while there are many links on Google, this is the first one I came across and it solved my problem.
    http://www.communitymx.com/content/article.cfm?cid=afc58
    Many thanks, Murray.

  • [php+mysql] nextensio list: how to change row color based on field content?

    Hi all
    I have a nextensio list on a page.
    is there a way to change the background color of a whore row based on
    a specific field content?
    example I have a field containing the values 0 or 1.
    If the field content is 1 the row background color should be RED.
    ANy suggestion?
    TIA in advance.
    tony

    DataBoundAPI's you can refer to achieve this.
    Search for OLD threads also. Here are some links:
    Can we colour the rows in the column of a table
    Advanced table row font color- result based change.
    Thanks
    --Anil
    http://oracleanil.blogspot.com/

  • Need to find table/field behind "Item long text" field in Notes tab in FB70

    Hello,
    To print a custom FI invoice, I need to access the data entered in the "Item long text" field of the Notes tab in FB70. To test, I used 5000 characters in that field to make sure it stood out from the rest of the data. F1 help does nothing on that field, and even running an SQL trace (ST05) doesn't show the text in that field being entered into any table. I tried F1 on a nearby field and got a structure instead of a table, so I investigated the structure through SE11 but found no character field with such a large capacity. How else can I find where that field is stored?

    Thanks! It took a while, but with your help and a few other pages I managed to piece together an answer.
    Vinod helpfully explained that the text name is a concatenation of various fields, but didn't specify how to find the line item ID. If you go to table STXH (as hinted by Brad and confirmed [here|http://fuller.mit.edu/SAPWebDocs/LongComment.html]) and search for texts created today (or whenever you were testing), you'll see the text name ends in '001' after GJAHR, so the line item ID is '001' regardless of how many line items you enter in the invoice.
    Armed with that info, you can call READ_TEXT and loop through the results to concatenate the contents of each TDLINE field. (FB70 automatically breaks the user-entered text into different lines even if the user didn't press Enter, and each line gets its own record in the results.)
    Thanks again,
    Pedro

  • Change Master Page based on Text Content

    Hello,
    I have found a few examples relating to changing Master pages based on Style.
    However, I would like to change all Pages that flag "True" with the query of the "2-1134" to to "Master-C" for example.
    I have 12 master Pages with different strings that I don't mind editing the script to make work.
    The document is close to 1,000 pages.
    I am having trouble merging so many different scripts into something that will work.
    Platform: Indesign CS4 6.0.5 - OS X (Intel)
    Thank you so much for your input, help and guidence.

    This is what layers are for. Open the Layers panel and make at least one more layer. Put the graphic on the lower layer and the footer on the upper layer.

  • Sorting incoming files based on payload content

    Hi,
      I have a file>XI-> FILE scenario...I need to sort the incoming file based on payload content...But my understanding is in XI each line item would be processed one at a time...Is it possible to sort the entire file before beginning to process???
    -Ken

    Hi Ken,
    you can try to create generic content sorting with java mapping:
    /people/ravikumar.allampallam/blog/2005/06/24/convert-any-flat-file-to-any-idoc-java-mapping
    Regards,
    michal

  • Exporting Table from Indesign to tagged text.

    Hi, all!<br />I need to export table from InDesign to tagged text by the script.<br />I found ExportAllStories.jsx in samples.<br />It's good example but I have some questions<br />1. In my document more then one table and I need to export only some of them. So, how can I export only one of them? May be Tables have some "labels" or something other differential sign?<br />2. How can I ser encoding type of distanation file (by the default InDesing set <ASCII-WIN>, but I'm need to set <Unicode>).

    Edit>InCopy>Export All Strories.
    Open the INDD in InCopy.
    This assumes everyone involved has access to the files.

  • Can I change the fill color of an entire row based on what's selected in a pop-up menu in the first cell?

    I have a pop-up menu in the first cell of every row with three choices (and I may add more at a later date).  I want the fill color of the row to change depending on which thing is selected.  Is this hard to do?

    Hi,
    In essence the same as Wayne's answer, but with a slight modification to fit  to duplicate your 'color the whole row' specification. The final result, with Table 2 slid behind Table 1, is shown.
    Table 2 is a single column table with the same number of rows as Table 1. The table is resized to match the full width of Table 1.
    In A2, use the formula =Table 1::A2 to copy the value from that cell in Table 2. Fill the formula down through the rest of the column.
    Select all the cells in Table 2 (except the header row), and apply conditional formatting rules such as those below.
    Note that the Conditional Format rules are set to apply the same colour to text and fill in the cell, so that the text disappears.
    When Table 2 is ready, select it, then go Arrange > Send to Back.
    Before sliding Table 2 behind Table 1, Select Table 1 and use the Table Inspector to set the Cell Background to None (see red arrow in illustration). If This table has a Header column, you need to select the header cells independently and again set the Cell Background to None.
    Now select Table 2 and drag it to a position partially under Table 1. When you see the blue alignment guides on both sides, or at the top and bottom, of Table 1, release the mouse button and use the arrow keys to nudge Table 2 into its final position.
    Regards,
    Barry

  • [AS] CS3- Find any text with style, then replace that text with a new applied fill color.

    I am trying to find the simplest way in cs3 to find any text with style, then replace that text with a new fill color. I can find text and change text. I can find a style and change it to a new style. I can't seem to find a style and change the applied fill color. I do not want to change the properties of the style, just the applied color. Yes, I want the + sign, for now. I know, why not update the style, I am not allowed to. Any help would be great. Since the search is not available, I need a new response.
    Thanks.

    You can work around the bug by just doing a find, then looping through the<br />results, changing the color one at a time. It'll be a fraction slower, but<br />should do the trick:<br /><br />tell application "Adobe InDesign CS3"<br />    set find text preferences to nothing<br />    set properties of find text preferences to {applied paragraph style:"The<br />name"}<br />    set theFinds to find text document 1<br />    repeat with i from 1 to count of theFinds<br />        set properties of item i of theFinds to {fill color:"Replace color"}<br />    end repeat<br />end tell<br /><br />The bug is fixed in CS4, BTW.<br /><br />-- <br />Shane Stanley <[email protected]><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>

  • Is it possible to apply conditional formatting to a cell (or range) based upon a LOOKUP query to cell values in another sheet.? I want to alter the formatting (i.e., text and/or cell background color), but not cell content.

    Is it possible to apply conditional formatting to a cell (or range) based upon a LOOKUP query to cell values in another sheet.?
    I want to alter the formatting (i.e., text and/or cell background color), but not the content, of the target cell(s).

    Hi Tom,
    Your LOOKUP formula will return a value that it finds in the "other" table. That value can be used in conditional highlighting rules. (Numbers 3 calls it conditional highlighting, not conditional formatting. Just to keep us awake, I guess, but it works the same).
    Please explain what you are trying to do.
    Regards,
    Ian.

  • Fill table cells with color % depending on cell content

    Hi.
    I'm working on a document with a lot of tables filled with percentages. The tables are originally on a Word document and the table cells are tinted according to their content: a value of 20% on the cell corresponds to a tint of 20%. This is done automatically on the Word document through a conditional formatting option that applies a graded color scale. Is there any way to do this in InDesign? I tried placing the tables and tried all options, but the color is not imported. Perhaps a script or a GREP style?
    Thank you.

    Conditional formatting in Word is done via formula, but in Excel it is handled more "on the surface" and Excel's conditional formatting carries into InDesign nicely via Place or Paste. It could be worth considering moving those tables into Excel.
    InDesign doesn't do this kind of formatting as a native function, but it couldn't hurt to ask about possible scripted solutions in the Scripting Forum.

  • Draw rectangle and apply fill color

    Hi
    anyone help me to draw rectangle outside artboard and apply fill color
    i want to draw 10 rectangle of same size and apply fill color using javascript
    Thak you
    appu

    Now that I am addressing the path items and text items of the group separately I am having some success. Now I am having difficulty getting the correct terms for assigning a Spot Color to the file. Here is a piece of the script.
    This works:
    tell application "Adobe Illustrator"
    set openDoc to document 1
    set ftClr1 to (first group item whose note is "Front3") of openDoc
    set ftClr1Paths to path items of ftClr1
    repeat with thisPath in ftClr1Paths
    set fill color of thisPath to {red:255}
    end repeat
    set textFrames to text frames of ftClr1
    repeat with thistext in textFrames
    set fill color of every line of thistext to {red:255}
    end repeat
    end tell
    Need help to set the fill color to a Spot Color that already exists in Swatches.
    Thanks
    Nick

Maybe you are looking for