[JS, CS2] Find Text - Change Paragraph Style

I have text supplied to me formated with <g>,< b>,<k> or <r> at the start of paragraphs, this represents different paragraph styles that need to be applied. <br /><br />I started a script below, but it comes up with an error at "app.findTextPreferences.findText" <br /><br />have a used the wrong function here? <br />Is there an easy way for it to run through all of them as well, or should I just repeat this script with < b>,<k> and <r><br /><br />var myDoc = app.activeDocument;<br />var greenBullet = ["<g>", "<g>"]<br />replaceGreen();<br /><br />function replaceGreen() {<br />for (i = 0; i < greenBullet.length; i++) {<br />            var myGreenArray = greenBullet[i];<br />            app.findTextPreferences.findText = myGreenArray[0];<br />            app.changeTextPreferences.changeTo = myGreenArray[1];<br />            app.changeTextPreferences.appliedCharacterStyle=myDoc.characteerStyles.item("OFI Body copy_GREEN BULLET");<br />            myDoc.changeText();<br />            }<br />}

Thanks Dave!<br /><br />OK, Now I am getting this message when I run it:<br /><br />"A layer with this name already exists...<br />...     if (myPageItems[i]  instanceof TextFrame && myPageItems[i].itemLayer.name = "listings")"<br /><br />So it's trying to create a new layer called listings.<br />Also - it seems to want to move the items to that layer?<br /><br />var myDoc = app.activeDocument;<br />app.findPreferences = null;<br />app.changePreferences = null; <br /><br />myObjectStyle = myDoc.objectStyles.item("defaultText");<br />myPageItems = myDoc.allPageItems;<br />for (var i = myPageItems.length - 1; i >=0; i--) {<br />     if (myPageItems[i]  instanceof TextFrame && myPageItems[i].itemLayer.name = "listings") {<br />          myPageItems[i].applyObjectStyle(myObjectStyle);<br />     }<br />}<br /><br />myDoc.search("<g>", false, false, undefined, undefined, {appliedParagraphStyle:"OFI Body copy_GREEN BULLET"});<br />myDoc.search("<k>", false, false, undefined, undefined, {appliedParagraphStyle:"OFI Body copy_BLACK BULLET"});<br />myDoc.search("<r>", false, false, undefined, undefined, {appliedParagraphStyle:"OFI Body copy_RED BULLET"});<br />myDoc.search("< b>", false, false, undefined, undefined, {appliedParagraphStyle:"OFI Body copy_BLUE BULLET"});

Similar Messages

  • How to find text or paragraph by giving style name?

    Hello,
    can any body tell me,How to find text or paragraph by giving style name?actully i have so many styles which is applied on document.
    i want to find text in the document which have particular style name.is any method to find text by giving name of style?

    Any of the various findText methods, plus your paragraph style name in FindTextPreferences: http://jongware.mit.edu/idcs5js/pc_FindTextPreference.html
    Use Google to locate exact samples, as this has been done countless times before.

  • [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;

  • GREP for changing paragraph style?

    Okay folks, I have another one for all you smart people out there. I think GREP can be used to change formatting in the following instance, but I have no idea how to set it up.
    I have a very long document, essentially a phone book-type listing of names, phone numbers, addresses, well over 150 pages' worth. The paragraph styles are fairly simple, only two per listing. The name/phone number is bold with a right hand tab with leader dots to a phone number that is flush to the right side of the column. The following lines are flush left, not bold, but indented 6pts. I've placed the text file and assigned the entire thing the NameListing paragraph style. I'd like to use GREP to find the address lines and change them to the NameListingAddress paragraph style.
    Here's a screen shot to give you an idea. The left column is formatted correctly with both styles, the right column is "raw", all paragraphs formatted with the NameListing paragraph style.
    Is this an appropriate application for GREP? If so, how do I set it up to only change the paragraphs that "don't have tabs"? It would save me a crapload of time.
    THANKS again! --Dina

    If your intent here is to use the character style to trigger a variable, as I belive it is based on your other thread, you MUST apply the character style up to the first tab to pick up the text at the start of the paragraph. There are two approaches to automating the formatting after that, but it may be too late for you to be much help.
    In cases where every listing has the same number of lines it makes sense to use a unique paragraph style name (not necessarily format -- base on on another) for each lline and make it its own paragraph. Set up "next styles" to rotate through the list so each line is assigned the correct style based on the style of its predecessor. You get the rotation to sart over by making the first line style the next style for the last line. This works for manual entry and can be applied to an entire block of placed text in a single operation by selecting the text, then right-clicking the name of the first style to be applied and choose Apply <stylename>, Then Next Style.This ONLY works if you have exactly the same number of paragraphs in each listing.
    The other option is to use forced line breaks instread of paragraphs and use one style for the entire listing. Set a left indent and negative first line indent, create a character style for the part of the first line that you want to appear in your header and apply it Up To ^t^n (that's a little-known trick -- if you enter more than one character in the trigger for a nested style it will activate on the first instance of any of the characters listed that occurs, so for example if you enter the word cat, your style will end on the first, c, a or t that appears inthe paragraph. ^t is the metacharacter for tab, and ^n is for forced line break) so that the style will end at either the tab, if present, or the forced line break if there is no tab (if you use a right-indent tab instead of a regualr right aligned tab [tricky to do a leader, but that's another discussion] substitute ^y for the ^t), then add a nested Line Style for one line. That line style should use a second character style that is based on the first character style you created for the name text and has no other attributes if you want the line to be the same from end to end. Sounds more complex than it is, and will work for listings with variable lenghths. The trick is to repalce your paragraph returns with forced line breaks, and will require a little thinking.
    If using separate paragraph styles for each line, you'd use the same technique of a nested style up to a tab for the first line, but there is no need to get fancier since it will apply to the whole line if there is no tab. The paragraph style, in this case, would carry all of the bold and size formatting (and no need for any indents), and the character style would be nothing more than a name that will allow you to use it in the variable.

  • Find and replace paragraph style

    I am creating a javascript for InDesign in order to search and replace some text. The text I am looking for has to be in a certain Paragraph style.
    This is what I have so far:
    app.findTextPreferences = app.changeTextPreferences = null;
    app.findTextPreferences.findWhat = '^p'
    app.changeTextPreferences.changeTo = ';'
    app.activeDocument.changeText();
    I need to find/change a return of a certain paragraph style to a semi colon. What is the script that I would use to search for paragraph style?

    try:
    app.findTextPreferences.appliedParagraphStyle = 'para style';
    If you want to replace the para style, use:
    app.changeTextPreferences.appliedParagraphStyle = 'new para style'

  • CS3 Find Font/Delete Paragraph Style/Redefine Paragraph Style Causes Crash

    I am running into a very frustrating issue where I cannot replace a paragraph style. The issue is that we used to use some adobe type fonts and want to move to the true type equivalent so that we don't have problems working on files between mac and pc. The problem occurs on both mac and pc on a variety of hardware (both c86 and ppc macs for example). When we open the document it identifies that the font cannot be found (example Palatino T1). When we click find font and select the regular ttf Palatino replacement and click Change All Indesign just vanishes and leaves a crash message with a ton of garbage and a read only memory error. The same happens if we change the font on some text and right click on aragraph style and click "redefine style" - there is a sudden crash.
    Trying to work around this I went into our templates and tried to change it there. Opening the paragraph style and selecting the new font caused it to crash upon selecting OK. Also trying to Make a new paragraph style works, but then when deleting the old one causes a crash no matter what combination of mapping or not mapping the old paragraph style we chose (we tried every option under the dialogue and selected several different styles to map to or none at all).
    This occurs on several different fonts and on several different templates. I have tried deleting the adobe font cache to no avail. Any help resolving this would be great - all our employees are going nuts over this problem.
    Thanks in advance for any help or suggestions!

    Peter, your latest post led me to an interesting revelation. When I change Palatino (t1) bold to Palatino Bold using Find/Change it is fine. When I change Palatino (t1) to any font using Find/Change there is a curious result! As soon as I click find first the page changes to the default template and all content is hidden. The 4 or 5 places where palatino occurs on the default template change fine, but then on the next click of FIND FIRST it crashes! So the problem is connected to "find first", not the actual change. My guess is this is an issue of with how the find/change jumps from the template to the individual page, but I'm not sure exactly what is happening.

  • [AS][CS3] Finding text with character style

    Please help to tell me how to find text with a specific character style and then delete the text.
    I had no problem doing this with CS2 but its doing my head in now.
    Thanks,
    Andrew

    Here you go. This assumes that your character style is at the top level of the panel. If you're using style groups, you'll need to write code to get at the style you want to use.
    //DESCRIPTION: Delete text in named character style
    (function() {
      if (app.documents.length > 0) {
        deleteStyledText(app.documents[0]);
      function deleteStyledText(aDoc) {
        var cStyle = aDoc.characterStyles.item("CharStyleName");
        setupFindText();
        app.findTextPreferences.appliedCharacterStyle = cStyle;
        aDoc.changeText();
      function setupFindText(find, change, wholeWd, caseSense, foots, hidLayers, lockedLayers, lockedStories, masters) {
        app.findTextPreferences = null;
        app.changeTextPreferences = null;
        try { app.findTextPreferences.findWhat = find } catch(e) {};
        try {app.changeTextPreferences.changeTo = change } catch(e) {};
        app.findChangeTextOptions.properties = {
          caseSensitive:(caseSense == null ? false : caseSense),
          wholeWord:(wholeWd == null ? false : wholeWd),
          includeFootnotes:(foots == null ? false : foots),
          includeHiddenLayers:(hidLayers == null ? false : hidLayers),
          includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
          includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
          includeMasterPages:(masters == null ? false : masters)
      } // end setupFindText
    Dave

  • Change paragraph style from X to Y in Pages Doc

    Hi
    Sorry for such a simple question, but I have looked through the Applescript manual and searched this forum and can't find a solution to my problem.
    All I want to do is loop through the paragraphs of a Pages document and if the paragraph style is "Body Full", then change it to "Body Half". I have tried if statements repeat statements and everything I can think of but can't seem to get it to work. I can loop through all the paragraphs and change them to "Body Half", but as soon as I try to select only those whose paragraph style = "Body Full" it doesn't change any.
    Here is an example of my attempt:
    tell front document of application "Pages"
    repeat with X from 1 to count (get paragraphs)
    if paragraph style of paragraph X = "Body Full" then
    set paragraph style of paragraph X to "Body Half"
    end if
    end repeat
    end tell
    If anyone could help I would be grateful. It's kind of embarrassing since I was a programmer for many years on mainframes and AS/400. Scripting is a new world to me.
    Thanks in advance.
    Jim

    Hello
    Jim Kahler wrote:
    I am also using iWorks 09. Now the indent level sets all paragraphs to the indent level of wherever the insertion point was when I ran the script.
    ? Still confused, it looks so easy!
    Jim
    Ok, i understand.
    Here is the solution :
    tell front document of application "Pages"
    set sel to selection
    set search_style to paragraph style "Body Full"
    set new_style to paragraph style "Body Half"
    repeat with X from 1 to count paragraphs
    tell paragraph X to if its paragraph style = search_style then
    select character 1
    set Y to indent level
    set its paragraph style to new_style
    set indent level to Y
    end if
    end repeat
    select sel
    end tell

  • Is there a script to change paragraph style based on even/odd page

    Is there a script or way to have paragraph style change between 2 styles based on the text being on an even or odd page? 

    @JustMikey – as I understand your task, the problem has nothing to do with "special" paragraph styles, but (nearly) all with anchored objects (the images and parts of the gray bar) and appropriate margin settings.
    Just see the following IDML file I exported from InDesign CS5.5:
    Dropbox - ImagesAwayFromSpine-CS5.5.zip
    ImagesAwayFromSpine-CS5.5.zip
         ImagesAwayFromSpine-CS5.5.idml
         080731_Manchester-xxl_Grau.tif
    Of course you could add paragraph styles to format the data automatically or optimize in other ways.
    That's up to you. But you can see the principle:
    Inspect the Anchored Object Options for the image and the gray bar. Also the frame fitting options for the image.
    Note: See also the margin settings, that are not exactly mirrored on even and odd pages (for good reason).
    Uwe

  • Change paragraph style of empty row using GREP

    Hello again ... another GREP query if anyone can assist!
    How can I change a completely empty paragraph line (like those found between verses in a poem, for example) to a different paragraph style so I can control the space better using GREP?

    Fair point ... but if I demonstrate:
    Text line here
    Text line here
    Text line here
    Text line here
    Text line here
    Text line here
    The empty row (4) between the two blocks is in the same paragraph style as the rest of the text. Indeed if lines 3 or 5 were in different styles I could remove the empty row and create a space using before/after spacing. But it is all in the same style. I was wondering if there was a way using GREP to change the para style of an empty row ie 4.

  • How to change paragraph style

    I have a text frame selected and it contains a story having various pargraph styles applied.
    I want to get name of each paragraph style applied in it and replace each with some other styles.
    But when I am applying style only one style is applied to whole text frame .(i.e all existing styles are replaced with a single style).
    Please help me , if there is any way.
    Thanks

    It was not a criticism of your design choices. You have misread my comments, I am simply warning you from long experience. We have no idea of what you do or don't know, most people who come here have little and it is safer to assume they have none.
    Creating a Textbox, which is randomly sized and placed and contains no text, is not dissimilar to having a Textbox already in the document with Placeholder text in it that you click on and it is replaced by whatever you type. If your client is quite familiar with Pages they must be familiar with using Placeholders and with duplicating and resizing objects as required. It is just a way of getting around your problem.
    Obviously you have done something else, or you would not be getting the results you have. I keep my version of Pages 5.5.3 as installed for testing, I don't know what you have done that is different and can't tell without having the file.
    If you want me to look, email me via my blue name. If not, that's fine too.
    Peter

  • What is the function to change paragraph styles?

    I'm trying to make a simple script that changes a raw data file that has preset Paragraph style already in the exported data from a HTML calender, and once its copied over into Indesign it changes the already existing paragraph style into a diffrent paragrph style?
    is this a simple script, I got no idea what the script function is to make the change of paragraphs.

    Would this work? or do I got the wrong function commands?
    var myInDesign = app
    var myDocument = app.activeDocument
    var myDocName = myDocument.name
    app.findParagraphStyle.caseSensitive = false;
    app.findParagraphStyle.wholeWord = false;
    app.findCharacterStyle.wholeWord = false;
    app.findCharacterStyle.caseSensitive = false;
    app.findParagraphStyle.findWhat = "SN.outabout.DAY-Gray";
    app.changeParagraphStyle.changeTo = "SN.Holiday-Day_of_the_week";
    app.documents.item(0).changeParagraphStyle();
    app.findParagraphStyle.findWhat = "SN.outabout.DATE";
    app.changeParagraphStyle.changeTo = "SN.Holiday-Month_and_Day";
    app.documents.item(0).changeParagraphStyle();
    app.findParagraphStyle.findWhat = "SN.listingsLT";
    app.changeParagraphStyle.changeTo = "SN.Holiday-Paragraph";
    app.documents.item(0).changeParagraphStyle();
    app.findCharacterStyle.findWhat = "SN.listingsBOLD";
    app.changeCharacterStyle.changeTo = "SN.Holiday-Title_Paragraph";
    app.documents.item(0).changeCharacterStyle();
    //myInCopy = CreateObject("InCopy.Application.CS3")  //Not sure if this would work, just crafting idea's.
    //var myDocument = myInCopy.ActiveDocument
    //var mySelection = myInCopy.Selection.Item(1)
    //var myStory = MySelection.ParentStory
    //var myText = myStory.Paragraphs.Item(1)
    //myStory.CheckOut
    //myText.ApplyParagraphStyle myDocument.ParagraphStyles.Item("zAPPROVED"), True
    //myStory.CheckIn
    Can I just do this with like a Nested If, then Statement?

  • Find a specific paragraph style within a table and apply a specific cell style?

    I'm a total beginner when it comes to scripting, but I would like to create a script that finds the paragraph style "resultsUL" within a large table and applies the cell style "female". Sure wish the find/replace was able to account for cell styles as well as paragraph and character styles. Is anyone willing to help me with this? Thank you!

    Hi,
    I do it quickly defining a simple research on the "resultsUL" para style and using a loop with QuicKeys as:
    Cmd-0 is a shortcut associated to the "female" cell style.
    So, What I do: search the para style (Cmd-option-F) and apply the cell style, then search again…
    As easy to do with QuicKeys, I think that can be easily done with a [JS] (faster process!).

  • Changing Paragraph Style Export Tagging Options

    I'm having a heck of a time trying to get the "Split Document (EPUB only)" box checked for certain styles. I was hoping an experienced scripter may be able to help me solve what I'm sure is an easy fix.
    My code snippet is below:
    var doc = app.activeDocument;
    var par_styles = doc.paragraphStyles.everyItem().getElements();
    for (var i = 0; i < par_styles.length; i++) {
         par_styles[i].styleExportTagMap.splitDocument = true;
    In this example, I'd like to get the Split Document checkbox checked for every paragraph style in my document. However, apparently the paragraph style doesn't support the "styleExportTagMap" class, which is the only place I've found that the "splitDocument" property lives.
    I assume my ignorance arises from not knowing exactly what the styleExportTagMap(s) class does.
    Could anyone point me in the right direction?

    Seems like a hack, but it works.
    var
        doc = app.activeDocument,
        par_styles = doc.allParagraphStyles,
        i = 0;
    for ( i ; i < par_styles.length; i++ ) {
        par_styles [ i ].styleExportTagMaps.add ( "", "", "", "" ).splitDocument = true;
    Hope that helps.
    Marijan (tomaxxi)
    http://tomaxxi.com

  • I cannot find the "Add Paragraph Style" option in the TOC inspector

    The Help Center under "Customize the table of contents" indicates that I can add a paragraph style to the TOC items list. However, when I follow the instructions on the help screen and click the "Add" pop-up menu, I can only add back one of the sections I have already removed. There is no option to add a paragraph style.

    For that choice to show, I believe it depends on which template (with which TOC type) you've selected. Some provide it and some don't.
    Create a new book and choose the 'Modern Type' template, then complete the same steps and you should be able to see what Help is referring to.

Maybe you are looking for

  • Unable to view data in ADF calendar.

    Hi, I am working on an adf application that uses the ADF calendar component. I have created view object(with Entity Object) and have dragged and dropped the associated component from the data controls as an adf calendar on a jsf page. But 'm unable t

  • How do you keep your place on the page

    we are trying to go paperless in my office, but the biggest complaint form the user is. "Hey when we did this on paper we never lost our place because we put a ruler under the line we were working on. We would stop printing if you can tell us how to

  • Help please, when I use my Macbook Pro internet it crashes our XBox Live

    When I use the internet at all on my Macbook Pro, wireless, it crashes the games my DF is playing on xbox live through the the same router but with the ethernet. It doesn't do this with his laptop PC. Any ideas?

  • Can i use flex components in flash?

    hi all, i recently downloaded flex and saw that the components have a much better feel than the components which ship with flash 8 pro. is there a way to use flex components in flash? any help would be appreciated. thanks, gaurav

  • PI webservice

    Hi We have created a PI webservice and provide the wsdl to a SOAP client. Now they want to consume it and pass the PI credentials to it. How can that SOAP client pass the PI credentials in their code ....is there a specific way or they can just add t