Script to apply cell style after search for paragraph

Hello,
can somebody help my do a script to search for all occurences of a paragraph format in tables and then apply a cell style to the enclosing cell for a document.
Thanks in advance.
Peter
BTW Mac InDesign CS 6

Hi,
use this:
var mDoc = app.activeDocument,
pST = mDoc.paragraphStyles.item("paraStyleName"),
cST = mDoc.cellStyles.item("cellStyleName"),
mFound, mParent, count;
app.findTextPreferences = null;
app.findTextPreferences.appliedParagraphStyle = pST;
mFound = mDoc.findText();
count = mFound.length;
while (count--) {
     mParent = mFound[count].parent;
     if (mParent.constructor.name == "Cell")
          mParent.appliedCellStyle = cST;
app.findTextPreferences = null;
edit paraStyleName and cellStyleName
Jarek

Similar Messages

  • A script to apply cell style to entire rows containing a specific text

    Hi,
    I am using InDesign CC 2014
    Does anyone know how to apply a cellstyle based on text contents found in a cell in javascript?
    I need to search the document and change cell style in entire row to "cellStyle01" if the text "someText" appear in cell.
    I've found similar script here in forum which apply table style, but don't know how to change it to apply cell style!
    var curDoc = app.activeDocument;
    var allTables = curDoc.stories.everyItem().tables.everyItem();
    app.findTextPreferences = app.changeTextPreferences = null;
    app.findTextPreferences.findWhat = "someText";
    var allFounds = allTables.findText();
    app.findTextPreferences = app.changeTextPreferences = null;
    for ( var i = 0; i < allFounds.length; i++ ) {
    var curFound = allFounds[i];
    if ( curFound.length == 1 ) {
    var curFoundParent = curFound[0].parent; 
    // curFoundParent.parent.appliedTableStyle = curDoc.tableStyles.itemByName( "tableStyle" ); 
    curFoundParent.parent.appliedCellStyle = curDoc.cellStyles.itemByName("cellStyle01"); 
    Thanks!

    Hi,
    Try this,
    var doc = app.activeDocument, 
        _tables = doc.stories.everyItem().textStyleRanges.everyItem().getElements(), 
        i, j, k, l, a, _rows,_cells, rowlen; 
    for(i =0;i<_tables.length;i++) 
        for(j =0;j<_tables[i].tables.length;j++) 
            _rows = _tables[i].tables[j].rows; 
            for(k =0;k<_rows.length;k++) 
                _cells = _rows[k].cells; 
                for(l =0;l<_cells.length;l++) 
                    if(_cells[l].contents == "someText") 
                        rowlen = _cells[l].parent.cells.length; 
                        while(rowlen--) 
                              _cells[rowlen].appliedCellStyle = doc.cellStyles.item("cellStyle01"); 
    Regards,
    Chinna

  • Im trying to download the new itunes so i can use my iphone 5 , however , the new itunes requires Mac OS X 10.6.8 or later and i cant seem to install that onto my imac even after searching for the new update (my imac is currently on 10.5.8.

    .Im trying to download the new itunes so i can use my iphone 5 , however , the new itunes requires Mac OS X 10.6.8 or later and i cant seem to install that onto my imac even after searching for the new update (my imac is currently on 10.5.8.

    You have already seen that you cannot load the new iTunes into your 10.5.8, so as Neil says, you need Snow Leopard (current cost £14).    And you'll probably need to update the disc you buy via the combo update, though that is free.
    As far as the new iTunes is concerned, there's been a certain amount of grumbling so you may want to study the forums before you update.   The main problem has been with album artwork which does not transfer easily.

  • When i click on 'Show all in Finder' after searching for anything on spotlight, NOTHING happens! No Finder window opens up and the spotlight dropdown menu just shuts! Please help!

    When i click on 'Show all in Finder' after searching for anything on spotlight, NOTHING happens! NO Finder window opens up and the spotlight dropdown menu just shuts! Please help!

    I'm having the same problem in other places as well, for example when i downloaded Easyfind right now, clicking the small magnifying glass button on the right of the file name (shown below) would usually open up finder highlighting the file, but now nothing happens when i click on that button!
    Is there a solution for this, as this was a very useful feature which i used ALL the time?

  • Search for paragraph overrides

    In CS 3, is there a way to search for paragraph overrides? I can "clear all overrides," but I'm concerned that this might make other, unwanted changes to my document. If I know there are no overrides, then I won't worrry about clearing them.

    I have this script preservelocalformatting.jsx and when I import text from word I execute the script on the selected text. It will apply character styles like, bold, italic, bold italic, subscript, superscript etc. to the selected text. I can then hit the Override button and know that nothing will change.
    The one catch though is to check the Type>Find Font for any fonts that don't have Bold or Italic, for example, I have fonts on my system called MetaPlus Normal, this has only italic in it's subset. I need the other font MetaPlusBold-Normal for bold text.
    But Type>Find Font and change whatever is needed. It's done really quick.

  • How to write script to apply character style?

    Hi,
    I'm on a Macbook pro and without a number pad so I can't assign a shortcut for the character styles. I did hear of a roundabout solution where you can assign a shortcut to a script which applies the character styles. Can anyone write this script?
    My character style is called 'Features bold'.
    I'm new to scripting, sorry if this is a dumb question.
    Cheers

    Hi,
    1. Save this code as .jsx file inside your Script Panel folder
    2. Apply a shortcut using Edit:Keyboard shortcuts... menu
    Option to choose:
    suggest to choose an option "context": "Text", so you can use more shortcuts which are busy with other contexts.
    #target indesign
    if (app.selection && app.selection[0].hasOwnProperty ("baselineShift") ) {
      var cName = "Features bold";
      var mCstyle = app.activeDocument.characterStyles.item(cName);
      if (mCstyle.isValid)
           app.selection[0].applyCharacterStyle(mCstyle);
      else
           alert ("CharStyle: " + cName + " not found");
    else
      alert ("Some text supposed to be selected...");
    Jarek

  • Dreamweaver cs5.5 opening files after searching for text code

    This just occured this afternoon.  I was working on a page and when I went to search for text in the code (ie "/head") dreamweaver would open a previously opened page.  In other words I was working on "walk.php" and when I did the search for "/head", dreamweaver opens "add_rsurvey_data.txt".  I know what the 2nd file is but I haven't opened it in months.  It's just a temp data file that my partner sent me.
    I'm using cs5.5
    Adobe will not help me.
    Thanks
    Glenn

    We don't get attachments from email replies here.  You would need to use the Camera icon in the actual web forum to a post screen shot.
    If this began yesterday, try deleting your Cache & restarting DW.
    http://forums.adobe.com/thread/494811
    Nancy O.

  • Is there a way to see app info after searching for an app by name on the iPad 2?

    I open app store on iPad.
    Search for an app by name.
    Results show up.
    I want to click the app like in iTunes to read the info about it, but the only option is to buy and install it.
    Shouldn't there be an option to view the info first?

    Tap tapping "Developer Web Site" or "Develoepr Page, or "App Support" or "More".
    Example. Open the App Store
    In the search field top right corner of the window type in:   Creative Postcard HD
    You should see "More" on the right with a down facing arrow. That should "expand" the window providing more information.

  • Need help showing singles and albums after searching for them In I Tunes 11 Win 7

    Just got I tunes 11 iusing Win 7 and when I add songs and search for them in the upper right hand corner the album or the song appears. NowI need to view the single so I can add info. But I cannot figure out where to click to jump to that single shown in the main display or the album shown in the main display window. Can somebody please help me? What to you click on? Thanks in advance. Also where are your playlists?

    I wanted to bring closure to this unanswered thread. I came to realize that I put way too much into that post (information overload) and couldn't possibly expect for anyone to take on such a compilation of driver issues all at once. I later put each issue into separate threads and then got the help I needed. I learned how to find out what the Hardware ID was for each one and got the appropriate software driver to match.
    Kudos go to Jerry_Lippey who helped me out in so many ways plus gave me the link to a page where I learned how do do this myself.
    That can be seen here: How to identify an unknown device (e.g. Wireless LAN module)?
    And, you can look up Hardware ID's here: PCI Vendor and Device Lists
    I hope this helps someone in the future who is the same boat that I was once in.

  • Grep Removing Characters when searching for Paragraph returns

    I'm currently working on an xml based business card file and the formatting requires me to search for a phone number followed by a End of Paragraph followed by a Page Break and then remove the unnecessary Paragraph Return. For some reason inDesign will not find an End of Paragraph then a Page Break through the following grep code "\r~P", however if I search for "\r\r" it will find it. I have been able to get this to work with "(\d{3}\.\d{3}.\d{4})\r\r" and then change to "$1~P", but each subsequent business card loses one number off of the end (804.777.7777, 804.777.777, 804.777.77 etc). What would cause this?
    Thank you,
    Brandon Boswell

    You should move this over to scripting (http://forums.adobe.com/community/indesign/indesign_scripting). You'll find people over there who can give you more help, if there is any.

  • Script to apply a style to currently selected text

    I can only find example scripts that work on complete files. What I want, is a script that works on currently selected text.
    If I can create a macro that applies a specific paragraph style to all currently selected paragraphs, or a character style to currently selected text, I can put that style under a shortcut key.
    That way, "emphasis" or "strong" can be put under ctrl-b, for example.
    If there is another way to achieve the same (in RH 9), I would be interested to hear it as well.
    Kind regards,
    Erwin Timmerman

    I had a quick look at Macro Express, but it seems that it only records key strokes and mouse clicks etc. This means that it only works if I have the style pod constantly open (which I do), always in the exact same position, with the same filter styles selected, and with the same CSS loaded, positioned at the same location in the scroll bar.
    Am I correct in assuming this, or is there a better way to program it?
    I am not sure this would be possible all the time. What's more, this script should work across multiple computers with different layouts, and with writers who don't really want to hack to get it working.
    With character styles there would be the possibility to automatically switch to HTML view, cut, write <span...>, paste, write </span>, go back to design view.
    But paragraph styles? That would be harder to do in HTML view, especially for multiple selected lines.

  • Cell edit: in search for the holy control center

    Struggling with fx cell editing turned up some issues, f.i. edits not always committed as expected (by me, expectation arguable, of course : -)
    http://javafx-jira.kenai.com/browse/RT-15336
    http://javafx-jira.kenai.com/browse/RT-15366
    the last with a comment "unless the API is changed it is not possible to commit by default". Which naturally drove me into trying to understand and trace the current work-flow, visualized in scribbles of the collaborators:
    http://www.flickr.com/photos/65941667@N02/6004789460/in/photostream#/
    Some verbal decoration to the picture (beware: all tainted by my ignorance : -)
    - looks like the place for client code (to a XXView, with XX == List, Table, Tree) which wants to modify its editing state is a method like
    edit(SomePosition p);
    // with
    SomePosition == int, TablePosition, ...- that method is used internally by the corresponding XX/Cell/Behaviour to either start or terminate an edit, the latter by simply setting the position to "out-off-range", like f.i. -1
    - the Cell is listening to that position and updates its editing state as appropriate. Doing so, it calls either startEdit or cancelEdit, which in turn notify the view's edit handler/s.
    - note that commitEdit is not part of the collaboration
    Now my comments:
    - there's a need for some place (be it on the cell or view level, don't know) which supports full edit semantics
    - a mere position is not strong enough to support those semantics
    - the start/commit/cancel methods on the cell are for internal usage by the cell (and its subclasses), probably shouldn't be public
    * Requests to start editing at the given position, returns true is started
    * or false if not possible for some reason
    boolean startEdit(SomePosition p);
    * Requests to terminate an edit and commit the new value, returns true is
    * committed or false if not possible for some reason.
    * Note: this is for use by external (to the cell) clients, which can't have
    * any knowledge about the current internal edited value!
    boolean commitEdit();
      * Requests to terminate an edit and throw away any new value.
    void cancelEdit();looks familiar, hehe ... sure: it's copied from Swing cell editor (the event parameter changed to a mere position). The open - and not really easy to answer - question is where to put it, and how to fit that into the all-controlled-by-listening-to-property-changes philosophy .. could be interesting.
    Cheers
    Jeanette

    Kleopatra wrote:
    Struggling with fx cell editing turned up some issues, f.i. edits not always committed as expected (by me, expectation arguable, of course : -)
    http://javafx-jira.kenai.com/browse/RT-15366
    yet another variant of "let the developer cope with the harder stuff" - it's closed as wont-fix (because we are unwilling to change a lacking api ...)
    CU
    Jeanette

  • Use Conditional Tags to apply different Style Sheets / Skins for branding purposes?

    RoboHelp HTML > WebHelp layout appearance using Conditional Build Tags
    I have a customer who supplies an application to different corporates, and brands his product by changing the appearance, using a selected style sheet to suit the Brand.
    Is there a way to customise a WebHelp layout, to select a style sheet and a skin for Brand A, and another style sheet and skin for Brand B, and so on?
    Would this work in RH7? (The customer uses this at the moment.)
    Would this work in RH8? (They could upgrade if this solves the problem.)
    Philip Tory, Technical Author

    Hi Phillip
    RoboHelp 8 offers an ability to nominate a specific CSS file in the Single Source Layout recipe. So sure.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • I can't click on anything in the search column drop after searching for artists/songs in the Search Bar?

    I can't click on anything inside the red circle once I search something.

    I HAVE FOUND A SOLUTION!!!!
    I was playing around with iTunes to see if it was one of the options so I tried this
    * Just uncheck "search entire library" and check it again!

  • How to apply a table cell style based on grep search?

    Anyone that know how to make a script that searches in an Indesign table for
    -> All cells where the text starts with "Banana"
    -> And apply cell style "Yellow" to these cells?
    I have been searching on forums for somedays and got this tip: https://github.com/seuzo/regex_cellstyle/blob/master/regex_cellstyle.jsx
    -> But that script is in japanese and also use dialogs.
    All help most appriciated!

    Hi Frankeman,
    Please try the below code, may it should be helpful:
    var myDoc = app.activeDocument
    app.findTextPreferences = app.changeTextPreferences = null
    app.findTextPreferences.findWhat = "Banana"
    var myFound = myDoc.findText()
    for(i=0; i<myFound.length; i++)
        if(myFound[i].parent.constructor.name == "Cell")
       myFound[i].parent.appliedCellStyle = "Yellow"
    Suppose the code is working fine for you, then please click correct answers.
    thanks
    Beginner_X

Maybe you are looking for

  • Calendar Month View, Scrolling

    In Mavericks, calendar month view, trackpad scrolling works but mousewheel doesn't.  Any solution?

  • Change Label name in a standard component in Performance mangement

    Hi All, My requirement is to change the label in a standard SAP component HAP_DOCUMENT_BODY . I am trying use CL_WD_LABEL-SET_TEXT for this.. But  I recieve a dump while doing the same. Could you knindly let me know the right process to do this. Than

  • BT Home Hub 3 and loss of Wi Fi when using either ...

    Dear Forums, Have been a BT broadband customer since 2012 and To tell you the truth I am completely dissatisfied with BT, the home hub and the help desk people. For the last 8 months I have been having problems either with Intermittent broadband, whe

  • How to get the gross weight of the material after packing in delivery ?

    Hello, We need to print the gross weight of the material after packing which includes packing material weight and target quantity weight for each material in the delivery. From which table the gross weight of the material after packing can be retriev

  • Very basic RMI questions

    I am having troubles finding technical information about how RMI works, exactly. Specifically, I can't find out how the JVM and RMI is working on the remote machine. Say you have the server app running and 2 clients invoke the same method at the same