Find based on style in CS2

Hi All
I am trying to write script for search based on paragraph style here is my code
var myDoc = app.activeDocument;
var myStylename = myDoc.paragraphStyles.everyItem().name;
var myStylenamelen = myStylename.length;
var myStyles = myDoc.paragraphStyles;
var mySlen = myStyles.length;
for (var a=0; myStylenamelen > a; a++) {
for (var j=1; mySlen > j; j++)
if (myStyles[j].basedOn == myStylename[a])
alert("Paragraph style " + myStyles[j].name + " " + myStylename[a]);
exit();
can anyone tell me what me doing wrong
Thanks
Shonky

Hi,
Is this what you want:
var myDoc = app.activeDocument;
var myStyles = myDoc.paragraphStyles;
var mySlen = myStyles.length;
for (var a=0; mySlen > a; a++) {
try {
alert("Paragraph style " + myStyles[a].name + " " + myStyles[a].basedOn.name);
} catch (e) { alert("Paragraph style " + myStyles[a].name + " undefined"); }
I don't know why you made the big construction when you can get the name of the basedOn with no extra effort. But that could be me.
I have inserted a try-catch because you get an error when you take a basedOn of a root paragraph style.
Greetz,
Glen

Similar Messages

  • Search Object Style in CS2

    Hi all,
    Im doing javascript for InDesign CS2. I need to find unused Object style through script.
    Please Help....
    Thanks in advance...

    Hi creativejoan0425
    I am not sure if I get your question rigth because my answer ist very short
    All you need is:
    var myDocAnz = app.documents.length;
    for (k= 0; k < myDocAnz; k++) {
         var myStories = app.documents[k].stories.everyItem().getElements();
    // your code
         for (i = myStories.length - 1; i >= 0; i--){
             var myTextFrames = myStories[i].textContainers;
             for (j = myTextFrames.length - 1; j >= 0; j--)    {
                 if (myTextFrames[j].contents == ""){
                     myTextFrames[j].remove();
                 } // if
             }  // for
         } // for
    } // for
    But with this script you remove every empty textframe
    Kind Regards
    Dani (from Switzerland)

  • How to find Based on PO item find ProjSt or Common Stock?

    Hi Gurus,
    How to find based on PO item and line item number find whether Project stock or it's common stock?  It's there any standard report is there? or provide me table name use with SQVI transaction code?
    Thanks and Regards,
    Deethya.B

    PO with account assignment category P - it is created for projects and need to provide account details in the tab.
    You can check these details from table EKPO - ( EKPO-KNTTP equal to P).
    Project stock can be finding in MMBE using special stock indicator as Q.  Details can be getting from table MSPR.
    Regards,
    Narendra.

  • Nested styles in CS2. Absence of property appliedNestedStyle

    In task I'm working on there is a subtask of extracting overrides from the text.
    The way I implement it is pretty straightforward: I iterate through all textStyleRanges. With each textStyleRange object I compare its style properties with style properties of paragraphStyle and characterStyle that are applied to it.
    Things are getting harder when nested styles come into play.
    When they are applied, they should be taken into account along with appliedParagraphStyle and appliedCharacterStyle.
    This issue also affects Drop Caps. When the character style is applied to Drop Cap this character style becomes nested.
    In CS3 scripting objects (textStyleRange, text, etc) has property appliedNestedStyle. So to extract overrides I can use it.
    But in InDesign CS2 there is no such property...
    So the question is how can I get applied nested style in CS2? Or maybe some workaround to accomplish the same goal?

    Indexes
    Scripting indexes has changed a lot. It finally works, and it works well. The property 'subtopic' has gone, instead you iterate the property 'topic' (up to three times). The following lines illustrate:
    if( app.activeDocument.indexes.length == 0 )
    myIndex = app.activeDocument.indexes.add()
    else
    myIndex = app.activeDocument.indexes[0]
    //create main topic
    myIndex.topics.add('dog')
    //create subtopics
    myIndex.topics.item('dog').topics.add('collie')
    myIndex.topics.item('dog').topics.add('setter')
    myIndex.topics.item('dog').topics.item('collie').topics.add('border collie')
    myIndex.topics.item('dog').topics.item('collie').topics.item('border collie').topics.add('*****')
    You can address (sub)topics by asking for topics embedded under topics:
    myIndex.topics[0].topics[0].topics[0].topics[0].name
    is the first subtopic of the first subtopic of the first subtopic of the first topic.
    A new property is allTopics: myIndex.allTopics returns an array of all (sub)topics. This is a flat, one-dimensional, array, i.e. it returns the whole index but without structure.

  • How to specify different horizontal restore & collapse icon for af|panelSplitter using Skinning based on Style class or position?

    Hello,
    I am trying to provide different horizontal restore & collapse icon for af|panelSplitter using Skinning based on Style class or position. I have 2 af:panelSplitter with orientation="horizontal" - One with positionedFromEnd="true" one with positionedFromEnd="false". I want to specify the horizontal collapse and restore icon using Skinning. I want specify different icons based on positionedFromEnd. When I specify icons they are appearing for both splitters. I gave 2 different styleClass to these splitter but it is not taking them in account,
    JSPX Page -
    <af:panelSplitter orientation="horizontal" splitterPosition="196" positionedFromEnd="false" id="pnlSplitterLeft" collapsed="false" styleClass="panelSplitterLeftClass">
      <f:facet name="first">
      <!-- Content of First Facets -->
      </f:facet>
      <f:facet name="second">
      <af:panelSplitter orientation="horizontal" splitterPosition="196" positionedFromEnd="true" id="pnlSplitterRight" collapsed="false" styleClass="panelSplitterRighClass">
      <f:facet name="first">
      <!-- Content of First Facets -->
      </f:facet>
      <f:facet name="second">
      <!-- Content of First Facets -->
      </f:facet>
      </af:panelSplitter>
      </f:facet>
    </af:panelSplitter>
    CSS Skinn
    af|panelSplitter::horizontal-restore-icon {
        width: 10px;
        height: 55px ;
        content : url("/skins/AppSkin/Left_Open.gif");
    af|panelSplitter::horizontal-collapse-icon {
        width: 10px;
        height: 55px ;
        content : url("/skins/AppSkin/Left_Close.gif");
    af|panelSplitter.panelSplitterLeftClass::horizontal-restore-icon {
        width: 10px;
        height: 55px ;
        content : url("/skins/AppSkin/Left_Open.gif");
    af|panelSplitter.panelSplitterLeftClass::horizontal-collapse-icon {
        width: 10px;
        height: 55px ;
        content : url("/skins/AppSkin/Left_Close.gif");
    af|panelSplitter.panelSplitterRighClass::horizontal-restore-icon {
        width: 10px;
        height: 55px ;
        content : url("/skins/AppSkin/Right_Open.gif");
    af|panelSplitter.panelSplitterRighClass::horizontal-collapse-icon {
        width: 10px;
        height: 55px ;
        content : url("/skins/AppSkin/Right_Close.gif");
    It is always showing Left_Open.gif and Left_Close.gif for both splitters. But I want different image.
    How to specify different horizontal restore & collapse icon for af|panelSplitter using Skinning based on Style class or position?
    - Sujay

    CSS attribute selectors are what you are talking about, but binding the selector with EL is a more-common approach. Using selectors like this require you to ensure browser support.
    af|panelSplitter.panelSplitterRighClass::horizontal-collapse-icon [positionedFromEnd=true]

  • Auto-set Conditional Build Tags Based On Style?

    Is there a way to auto-set conditional build tags based on style?
    I want to be able to import a Word document into RoboHelp and have it recognize certain styles as requiring certain conditional tags. For example, an imported Word document might have a style called WD_Internal and any text with that style would automatically have a conditional build tag assigned to it. The idea is to allow my SMEs to indicate which text is intended for internal audiences and which text is OK for customer consumption in a single central Word document using styles. When the content is correct, I'd import it into RoboHelp, have RoboHelp assign conditional build tags, then generate multiple printed versions of the document (an internal version and a public consumption version).
    Setting conditional build tags is pretty easy, but it will still be a lot of work to manually set them. Is there a way to do this automatically?
    I am using RoboHelp HTML RH9.

    Hi,
    There's no way to do this through the interface. You can however create a script to do this for you. Cycle through the content of the topics and insert the code for the CBT.
    Greet,
    Willam

  • JS:CS3 Newbie needs help! find/change character styles

    I'm new to scripting and JavaScript is giving me a headache, but I'll keep trying. What I'm trying to do is automate a few things so that the production time of our school newspaper is reduced while insuring accuracy.
    I've played around a little with the text find change sample and the changing or adding paragraph styles in the InDesignCS3_ScriptingGuide_JS.pdf and I barely understand what I'm doing.
    When us page designers receive text to place in the document, our editors mark the text with tags like: < b >text< / b >, where the word "text" is to be bolded. (there wouldn't any spaces between < and b and > etc. I just did that so It'll show up here). We have basic character styles and paragraph styles set up, and we just started working with nested styles.
    Is there a way we can search for the < b > tag and bold everything after it up until the < / b > tag? Sort of the way it does for html (the way it would do for this message if I took out the spaces). It'll be great if it could remove the tags as well, but if not, I know I could create a find/change script to do the removal afterwards.
    I appreciate any input.
    Thanks!

    You've not found yourself the easiest of tasks! You need GREP find/replace, not text. Do you have any experience with GREP? It's worth investigating, it's a powerful feature. The script below handles bold. For clarity, it doesn't do any error checking: it assumes that there's a document with text in it and that the document contains a character style called 'bold'.
    // talk to Indesign, nobody else
    #target indesign
    // reset the Find/Change dialog
    app.findGrepPreferences = app.changeGrepPreferences = null;
    // find everything between <b> and  (including these codes)
    app.findGrepPreferences.findWhat = '<b>.+?</b>';
    // add 'bold' style
    app.changeGrepPreferences.appliedCharacterStyle = 'bold';
    // make the changes
    app.activeDocument.changeGrep();
    // now delete the <b> and </b> codes
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = '</?b>';
    app.changeGrep();
    You can adapt it easily to handle other codes, and at a later stage you could generalise it so that you needn't repeat whole bunches of code.
    Good luck with your first forays. Again, it's not the easiest of tasks, but it's worth getting to grips with.
    Peter

  • [win][js][cs4]find/change paragraph styles without losing local overrides

    Hi guys i need a little help here.
    I created a javascript which will find and replace doc file paragraph styles with indesign paragraph styles. everything works fine but the problem is that when it applies the paragraph styles it loses all local overrides. i tried:
    changetext(false);
    but its not working is there some kind of conditional parameter that i can put in the changetext() function so that it wont clear local overrides?
    Thanks.
    CharlesD

    Thanks Kasyan. You're always there to save my day. Thank you very much...
    I slightly modify the script to go through all my paragraph styles that need to be replaced coz there are hundreds of them. Im not sure though if this is the best or is there any faster way to do this:
    replace("T1", "Text", "T1");
    replace("T", "Text", "T");
    replace("1", "Heads", "1");
    replace("2", "Heads", "2");
    function replace(input, folder, output) {
        var foundItem;   
        var doc = app.activeDocument;
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
        app.findGrepPreferences.findWhat = ".+";
        app.findGrepPreferences.appliedParagraphStyle = input;
        var foundItems = doc.findGrep();
        for (var i = 0; i < foundItems.length; i++) {
            foundItem = foundItems[i];
            foundItem.applyParagraphStyle(doc.paragraphStyleGroups.item(folder).paragraphStyles.item( output), false);
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

  • Finding "End Nested Style Here" option

    Hi,
    How to find and replace the "End Nested Style Here" marker through InDesign CS3-JS.
    Thanks,
    P. Ramkumar

    If you use findText, you can find it using ^h
    In findGrep it is ~h
    Dave

  • Problem Mapping Tags to Styles in CS2

    Hello, I am running CS2 (V4.0.5) on XP SP2. I have XML-tagged text that I am mapping to styles/map by name. While the paragraph styles apply correctly, character style sheets that shouldn't apply are being applied as well. I have replicated this multiple times.

    Hi,
    Can you provide some text examples from your xml file. This because to identify the concern in the xml coding.
    Regards
    Thiyagu

  • Replacing based on style

    Hello,
    I have a series of documents in which a number of stylesheets are based on "Basic Paragraph". I want to change them all to be based on No Paragraph Style. The script below targets the correct folder (Fonts, within General), but there is something wrong with my syntax in the loop (line 15).
    Thanks in advance for any help with this.
    Tim
    var myDoc = app.activeDocument;
    var theseStyles = myDoc.paragraphStyleGroups.itemByName ("General");
    var targetStyles = theseStyles.paragraphStyleGroups.itemByName("Fonts");
    var numberStyles = targetStyles.allParagraphStyles.length;
    alert(numberStyles);
    for  (var i = 0; i<numberStyles; i++){
        var currentStyle = targetStyles.allParagraphStyles[i];
        if (currentStyle.basedOn = "Basic Paragraph"){
            currentStyle.basedOn = "No Paragraph Style";

    Thanks Chinnadk - that works now. But am i right in thinking that you have replicated my original mistake, and the first line should read:
    if (currentStyle.basedOn == myDoc.paragraphStyles.item("[Basic Paragraph]")){
    ie. two equals signs to test truth, rather than one to assign value.

  • XMP data find in CS not in CS2

    Our product uses the XMP SDK version 2.9.  While I would like to upgrade to a more recent version, it is not completely practical for the shipping code.<br /><br />We have encountered a file with XMP data we wrote using this SDK which is then inserted into a jpg file.  The resulting XMP data is completely read by Photoshop CS and by our application MediaBin, but when the same file is read into Photoshop CS2 only a subset of the data (specifcally the URL and the custom tags) appear and the description, for example, does not.<br /><br />Are there known incompatibilities between the older SDK and Photoshop CS2?<br /><br />I append the data (with customer data excised) below.<br /><br />Thanks for any feedback,<br /><br />Lyman Hurd<br />Interwoven, Inc.<br /><br /><?xpacket begin='&#65279;' id='W5M0MpCehiHzreSzNTczkc9d'?><br /><x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP toolkit 2.9-9, framework 1.6"><br />    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"<br />        xmlns:iX="http://ns.adobe.com/iX/1.0/"><br />        <rdf:Description rdf:about="" xmlns:xap="http://ns.adobe.com/xap/1.0/"<br />            xap:MetadataDate="2006-08-21T19:14:05Z"/><br />        <rdf:Description rdf:about="" xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/"<br />            xapRights:Marked="True" xapRights:WebStatement="http://www.xxxxximages.com"/><br />        <rdf:Description rdf:about="" xmlns:mbn="http://ns.interwoven.com/mediabin/1.0/"><br />            <mbn:tag>#MB%:{88E1EC23-B253-4C79-8944-772852879E8F}ILMEDIABIN:%MB#</mbn:tag><br />        </rdf:Description><br />        <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"><br />            <dc:rights><br />                <rdf:Alt><br />                    <rdf:li>Copyright © XXXXX. All Rights Reserved.</rdf:li><br />                </rdf:Alt><br />            </dc:rights><br />            <dc:title><br />                <rdf:Alt><br />                    <rdf:li>Picture Description</rdf:li><br />                </rdf:Alt><br />            </dc:title><br />        </rdf:Description><br />        <rdf:Description ID="http://ns.adobe.com/xap/1.0/"><br />            <iX:changes><br />                <rdf:Bag><br />                    <rdf:li>Title,2006-08-21T19:14:05Z,5,c</rdf:li><br />                </rdf:Bag><br />            </iX:changes><br />        </rdf:Description><br />        <rdf:Description ID="http://ns.adobe.com/xap/1.0/rights/"><br />            <iX:changes><br />                <rdf:Bag><br />                    <rdf:li>Copyright,2006-08-21T19:14:05Z,3,c</rdf:li><br />                    <rdf:li>Marked,2006-08-21T19:14:05Z,6,c</rdf:li><br />                    <rdf:li>WebStatement,2006-08-21T19:14:05Z,7,c</rdf:li><br />                </rdf:Bag><br />            </iX:changes><br />        </rdf:Description><br />        <rdf:Description ID="http://ns.interwoven.com/mediabin/1.0/"><br />            <iX:changes><br />                <rdf:Bag><br />                    <rdf:li>tag,2006-08-21T19:14:05Z,1,c</rdf:li><br />                </rdf:Bag><br />            </iX:changes><br />        </rdf:Description><br />        <rdf:Description ID="http://purl.org/dc/elements/1.1/"><br />            <iX:changes><br />                <rdf:Bag><br />                    <rdf:li>rights,2006-08-21T19:14:05Z,2,c</rdf:li><br />                    <rdf:li>title,2006-08-21T19:14:05Z,4,c</rdf:li><br />                </rdf:Bag><br />            </iX:changes><br />        </rdf:Description><br />    </rdf:RDF><br /></x:xmpmeta><br /><?xpacket end='w'?>

    XMP is a powerful metadata format and I believe that it can be written directly to any mov or mp4 format media but not other formats such as mts. I have also experimented with using Prelude, Bridge, and Premiere to try and tag my footage. The conclusion I came to was that it just isnt worth the effort yet. None of them really communicate with each other very well and the interface for searching metadata (even after painfully inputting it using their metadata panels) is slow and cumbersome. Adobe did great by creating xmp, and lots of highend propriety software solutions for broadcast seem to be using it with custom software but there is nothing at the low end for normal users. Bridge doesn't seem to have been touched in several years. Even Lightroom, which would appear to be Adobe's most natural video tagger/organiser for the prosumer, doesn't create searchable usable tag data for use with Premiere. Right now I would say a good folder structure, using Finder's tag system (if you are on a mac), and spreasdsheets are the best way to work on smaller projects. Just my $2.

  • IDCS3 Windows: Finding a font style

    I recently added a font style "Exp" to my Plantin family of fonts in InDesign CS3. The others all came in one package, but Plantin Exp I downloaded from another source. When I list the typefaces in InDesign from the bar at the top of the screen, 'Plantin' now appears twice: once with all the original styles, the second with just "Exp". That is manageable for manual work, but when scripting, and trying to find a character in Plantin Exp, the script misses it. There may be a fault in the installation of the new font style. Is there any way around this in scripting?

    Hi Again David!
    On This Page, City BQ Volume looks close.
    ali b

  • Path finding based on an image

    I know its possible to create a path finding algorithm based on an image... That is, if the color map is blue then there is water, if it is brown then there is land. So detection of land and water is not the problem.
    What I want to know is, is there an easy way to set up a path finder aside having a for loop try all the possibilities? The loop should follow logical paths rather than iterate through each turn...

    I'd try an image processing forum. This forum is typically for Java-specific issues and there might not be that many people who've done this here. Sorry I couldn't help. Have you read some image processing books?

  • Find out which style is not being used

    Hi,
    I am viewing my long forgotten css code, i find that the code
    probably redundant, I like to know how to find out if any element
    or any pages/file in the project is using that particular style or
    not? So i can completely delete it

    Do a sitewide FIND for any given class or ID selector. But
    you would have
    to do this selector-by-selector. There is no sitewide report
    to grab them
    all.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "RunRunforest" <[email protected]> wrote in
    message
    news:gfbohc$9ua$[email protected]..
    >i am using cs4

Maybe you are looking for

  • Blank page with quick reply on all mybb forums, the same thing was with Fire fox 3.0.1?

    blank page with quick reply on all mybb forums, the same thing was with Fire fox 3.0.1? == URL of affected sites == http://world.alnel.com

  • Disable right click on pictures

    Hi, I've been asked to disable the 'right mouse click' on pictures so that they can't be downloaded. Personally I see little point in doing this as some one can easily print the screen and get the images that way but hey if that's what someone wants,

  • Setting photos as wallpaper

    Each time I choose a photo from my gallery to make a wallpaper it gets enlarged and distorted. Is there a way to set a photo as wallpaper without zooming in?

  • Link in flash mvoie

    Hi, I'm pretty crap at flash and i have what is probably a simple question. I want to create a link for one layer of a flash animation, for multiple frames. How do i do thi? Thanks a lot. Olly

  • Kernel_task cpu usage and fans on high (slow system)

    Ok so I have a fairly new MacBook Pro that is acting up. It is probably 2 months old and I noticed the kernel_task has spiked using majority of cpu (system% is in the 90's). So I went through cleaning out cache, temp files, trash, etc... then removed