apply existing styles to paragraphs

I have a little problem. How to apply existing styles. Different style to the first, second and third paragraph of the story/selection. I think it's simple, but I can't solve the problem. Thank you.

It's pretty easy:

mySelection var = app.selection [0];

var paraStyle1 = app.activeDocument.paragraphStyles.itemByName ("style1");

var paraStyle2 = app.activeDocument.paragraphStyles.itemByName ("style2");

etc.

mySelection.paragraphs [0] .appliedParagraphStyle = paraStyle1;

mySelection.paragraphs [1] .appliedParagraphStyle = paraStyle2;

etc.

Tags: InDesign

Similar Questions

  • Apply the style of paragraph 1 above and the style of paragraph 3 below all paragraphs containing only the italics?

    Hello

    I need a script that can find the paragraphs in italics only glyphs (maybe we can change all that pretty color) and apply the style of paragraph 1 above, the style of paragraph 3 below and this paragraph in italics to paragraph style 2

    Some paragraph of text (for the 1 paragraph style)

    some italic text (for paragraph style 2)

    little text (for the 3 paragraph style)

    After you run the script, I have something like this in 3 styles different points

    a text

    some italic text

    a text

    Lost link!

    /*

    Fixing paragraph style combinations

    Version: 1.2.B

    Script by Thomas Silkjaer

    http://indesigning.NET/

    Minor version b: Bruno Herfst

    + Add any style to replace paragraphs

    + Can cancel

    */

    var the_document = app.documents.item (0);

    Create a list of paragraph styles

    var list_of_paragraph_styles = [];

    var all_paragraph_styles = [];

    the_document.paragraphStyles.everyItem () .name;

    for (i = 0; i< the_document.paragraphstyles.length;="" i++)="">

    list_of_paragraph_styles.push (the_document.paragraphStyles [i]. (Name)

    all_paragraph_styles.push (the_document.paragraphStyles [i]);

    }

    for (i = 0; i< the_document.paragraphstylegroups.length;="" i++)="">

    for (b = 0; b< the_document.paragraphstylegroups[i].paragraphstyles.length;="" b++)="">

    list_of_paragraph_styles.push (the_document.paragraphStyleGroups [i] .name + ' /' + the_document. paragraphStyleGroups [i] .paragraphStyles [i] .name);

    all_paragraph_styles.push (the_document.paragraphStyleGroups [i] .paragraphStyles [i]);

    }

    }

    var list_of_replace_paragraph_styles = list_of_paragraph_styles.slice (0);

    list_of_replace_paragraph_styles.unshift ("[no paragraph style]" "");

    That the dialog box to select the paragraph styles

    var the_dialog = app.dialogs.add ({name: 'Paragraph style pairs Fix'});

    {with (the_dialog.dialogColumns.Add ())}

    {with (dialogRows.Add ())}

    staticTexts.add({staticLabel:"Find:"});)

    }

    {with (borderPanels.Add ())}

    var find_first_paragraph = dropdowns.add ({stringList:list_of_paragraph_styles, selectedIndex:0});})

    staticTexts.add ({staticLabel: "monitoring of"});

    var find_second_paragraph = dropdowns.add ({stringList:list_of_replace_paragraph_styles, selectedIndex:0});})

    }

    {with (dialogRows.Add ())}

    staticTexts.add({staticLabel:"Change:"});)

    }

    {with (borderPanels.Add ())}

    var change_first_paragraph = dropdowns.add ({stringList:list_of_paragraph_styles, selectedIndex:0});})

    staticTexts.add ({staticLabel: "monitoring of"});

    var change_second_paragraph = dropdowns.add ({stringList:list_of_paragraph_styles, selectedIndex:0});})

    }

    }

    {if (the_dialog. Show())}

    Define paragraph styles

    var find_first_paragraph = all_paragraph_styles [find_first_paragraph.selectedIndex];

    anyStyle var = false;

    If (find_second_paragraph. SelectedIndex == 0) {}

    anyStyle = true;

    }

    var find_second_paragraph = all_paragraph_styles [find_second_paragraph.selectedIndex - 1];

    var change_first_paragraph = all_paragraph_styles [change_first_paragraph.selectedIndex];

    var change_second_paragraph = all_paragraph_styles [change_second_paragraph.selectedIndex];

    Set preferences for grep to find to find all the points with the first selected paragraph style

    app.findChangeGrepOptions.includeFootnotes = false;

    app.findChangeGrepOptions.includeHiddenLayers = false;

    app.findChangeGrepOptions.includeLockedLayersForFind = false;

    app.findChangeGrepOptions.includeLockedStoriesForFind = false;

    app.findChangeGrepOptions.includeMasterPages = false;

    app.findGrepPreferences = NothingEnum.nothing;

    app.findGrepPreferences.appliedParagraphStyle = find_first_paragraph;

    app.findGrepPreferences.findWhat = ' $';

    Search current history

    var the_story = app.selection [0] .parentStory;

    var found_paragraphs = the_story.findGrep ();

    var change_first_list = [];

    var change_second_list = [];

    Browse the paragraphs and create a list of words and mark them as index words

    myCounter = 0;

    {}

    try {}

    Create an object to in paragraph reference and the following

    var first_paragraph is found_paragraphs [myCounter].paragraphs.firstItem ();.

    var next_paragraph = first_paragraph.paragraphs [-1] .insertionPoints [-1] .paragraphs [0];

    {if (anyStyle)}

    change_first_list.push (first_paragraph);

    change_second_list.push (next_paragraph);

    } else {}

    Check if the next paragraph is equal to the find_second_paragraph

    if(next_paragraph.appliedParagraphStyle == find_second_paragraph) {}

    change_first_list.push (first_paragraph);

    change_second_list.push (next_paragraph);

    }

    }

    } catch (err) {}

    myCounter ++;

    } While (myCounter<>

    Apply paragraph styles

    myCounter = 0;

    {}

    change_first_list [myCounter] .appliedParagraphStyle = change_first_paragraph;

    change_second_list [myCounter] .appliedParagraphStyle = change_second_paragraph;

    myCounter ++;

    } While (myCounter<>

    Alert ("fact pairs fixation!");

    }

  • Clicking on a paragraph Style does not apply text Style

    I just switched from a PC to a whole new MacBook Pro (OS x 10.7 Lion), and InDesign CS5.5 bought. I use CS4 on a PC for a few years and had no problems. For some reason, I can't apply Styles to paragraph by moving my cursor in the text and clicking the paragraph style. It highlights the style clicked for a while and then goes to value all styles, but does not apply the changes. The only way I can apply a Style of paragraph right now is click with the right button on the style and selecting 'apply... '. "in the menu dropdown. It is very curious. I was wondering if anyone had experience with this. I also have Microsoft Office: Mac 2011 installed on the laptop, if it makes a difference to anyone. Any help would be greatly appreciated, since I dial and change my life, and this problem slows me down a bit.

    Right on any of the third party plug-ins. It was actually 'good Zoom '. A third-party application that corrects some native zonky zoom behavior for Mac. I disabled it, and it has cleared up the problem. It's pretty strange, however, isn't it? Thanks for your help!

  • Can character or paragraph automatically apply a style to recurring words in a document?

    Can you character style or paragraph search for recurring words in a document and automatically apply a style? For example to make some "BOLD" words that appear several times in a document? To help Windows and must currently Adobe InDesign C.

    You can add a GREP style to a paragraph style to apply a character style to any match for your GREP expression, which may be your Word.

  • Help: apply different styles of Pará to several consecutive paragraphs using the script

    Hi all

    I need to apply different styles of Pará to several consecutive paragraphs using the script, something like this (found somewhere on the net):

    myDoc = app.documents var [0];

    mySel var = app.selection [0];

    var myPStyle1 = "A";

    var myPStyle2 = 'B ';.

    you need to add 6 styles here:

    var myPStyle3 = 'C ';

    var myPStyle4 = "D";

    var myPStyle5 = 'E ';

    var myPStyle6 = 'F';

    var myPStyle7 = "G";

    var myPStyle8 = 'H ';

    the last style is not necessary in the script?

    apply style 1 paragraph 1

    mySel.appliedParagraphStyle = myDoc.paragraphStyles.item (myPStyle1);

    apply styles to the paragraphs after selection

    style 2

    mySel.paragraphs [-1] .insertionPoints [-1] .appliedParagraphStyle = myDoc.paragraphStyles.item (myPStyle2);

    next style

    mySel.paragraphs [-1] .insertionPoints [-1] .paragraphs [0] .insertionPoints [-1] .appliedParagrap hStyle = .nextStyle myDoc.paragraphStyles.item (myPStyle2);

    I tried a lot, but could not find the way to extend the sequence

    Sorry, no skills in the scripts still...

    all styles have "Next Style" option enabled, but I can't use ' apply style, then next style "or object styles, because I need four different sequences of these paragraph styles:

    A-B-C-D-E-F-G-H

    A-B-D-E-G-H

    A-C-D-F-G-H

    A-D-G-H

    and I don't really want to create special clones of the same style for each sequence (Keep It Simple, they say ).

    I think that this can be done through four slightly adjusted scripts...

    any suggestions would be greatly appreciated...

    Sorry to be late to the party, I usually take up such things immediately.

    How about this one?

    1. no separate necessary script, it uses a small dialog box where you can choose what style to use. If I'm not mistaken, you can press a digit key on Windows to immediately select one of the items.

    2. it works down in the paragraph in that your cursor is located. It has nothing to do with the blocks of text, even if - consecutive paragraphs within a story always ignore the text frames.

    3. extensible: you can easily change the names of the styles in the table at the top of the page and the number of groups of style in the list.

    var styleLists = [
              [ "A", "B", "C", "D", "E", "F", "G", "H" ],
              [ "A", "B", "D", "E", "G", "H" ],
              [ "A", "C", "D", "F", "G", "H" ],
              [ "A", "D", "G", "H" ]
    ];
    
    var radiobutts = [];
    
    styleDialog = app.dialogs.add ({name:"Set Multiple Styles",canCancel:true});
    with (styleDialog)
    {
              with (dialogColumns.add())
              {
                        with (radiobuttonGroups.add())
                        {
                                  for (i=0; i		   
  • How to apply several styles of one-sentence paragraphs?

    I'm using paragraph styles, but is not useful because I am applying 2 different styles in the same sentence that does not work.

    To make it work, I selects the sentence, apply the style, for example 'xfont-regular"then I select the word in the sentence that I want to have a different style and I choose in the list perhaps italic police so that it looks like 'something like this'

    Of course, in doing so, I lose all the benefits of the use of styles p and of course, it's so your time. Is it possible to break down the sentence, now in the same line, so that I can apply different styles to it? and always keep the benefits to go just to styles and make the changes to the entire document that this style is applied.

    Thank you

    pchinique wrote:

    I'm using paragraph styles, but is not useful because I am applying 2 different styles in the same sentence that does not work.

    To make it work, I selects the sentence, apply the style, for example 'xfont-regular"then I select the word in the sentence that I want to have a different style and I choose in the list perhaps italic police so that it looks like 'something like this'

    Of course, in doing so, I lose all the benefits of the use of styles p and of course, it's so your time. Is it possible to break down the sentence, now in the same line, so that I can apply different styles to it? and always keep the benefits to go just to styles and make the changes to the entire document that this style is applied.

    Thank you

    As Diane King mentioned, nested character styles may work for your need. His example was an initial capital of fall (multiline first one or several letters of a paragraph.) Dropped caps are a particular type of nested style - always the very first one or more characters in a paragraph, high on two or more lines.

    To use the general type of nested style, you must be able to identify the words in the paragraph which gets the nested character style. For example, the third word, or the first two words after the first semicolon. If there is no model of Word (s) that can be identified by the post office or the sequence, it is possible that a GREP style can be used to find a common pattern of characters and apply a style of character to it, for example a phone number, the date, or the amount of currency that is identified by a dollar sign book, or yuan.

    Search Help for InDesign and Google "Style nested InDesign', 'InDesign grep Style' and similar (without the quotes) terms for more details. There has been many discussions of GREP on this forum.

    HTH

    Kind regards

    Peter

    _______________________

    Peter gold

    Know-how ProServices

       
  • A paragraph style that applies to all other paragraph styles?

    Hello

    How do you add a paragraph style that applies to all other paragraph styles?

    I tried to apply my master styles desired to [standard paragraph] and then from all the other paragraph styles [standard paragraph], with styles that apply indirectly, for example title 1 is based on [standard paragraph] but section 2 is based on heading 1 and so on.

    This does not work as well as I expected.

    Is there anything else I can do?

    Much obliged!

    A rule of thumb is to leave the only standard paragraph. Otherwise you can mess up other styles based on that.

    To set up your new style - which may by default based on the standard paragraph - and formatting you wish. Then base on that other styles.

    k

  • Add style to large block of text without affecting existing styles within this text

    Hello! First post here.

    I have a long text document which for the most part, has no attached text styles (it was a mistake). However, there are a large number of stylized breast text boxes.

    Is there a way to select all of the text and apply a style to the text without style without affecting the existing styles?

    Doing so by hand by text block text block would take a very long time.

    Any help is greatly appreciated.

    THX!

    Ian

    What do you mean by "text without style? There must be a definition, anyway.

    Like others, [no paragraph Style] and [standard paragraph] are available, too.

  • Impossible to properly apply a style

    This is the second time when I can't do a paragraph style be applied in a way that it is supposed to. Say, I use tripped 18pt, bold font style. I select a portion of text container and make a style of it. I then click the style to assign to a new paragraph but it holds tightly tripped 18pt Simple. How do I make it work or is it a bug?

    Pages ' 09 (4.2)

    You have probably mixed style is in the initial paragraph that you did the Style from which in the paragraph you want to apply the Style to.

    To make sure that the original style does only one font etc type a short series of words so that it starts and ends even, apply all of your properties to that, then set a new-Style.

    To force a Style to a paragraph, click in the text and double click on the name of the Style in the Styles Palette.

    Peter

  • With the help of several styles of paragraph in a table cell

    Hello

    I'm stuck using several styles of paragraph within a cell. I guess the solution is that I need to start a new paragraph, but so far I have not found a way to do it. When I directly in InDesign, it works fine, but I can not start a new paragraph when you use the script.

    Here's a solution I've tried:

    with {(table)

    .properties de.insertionPoints.item-(1) lines [0] .cells [0] = {}

    content: '1 ' Format string,

    appliedParagraphStyle: styleFormat1

    };

    .properties de.insertionPoints.item-(1) lines [0] .cells [0] = {}

    content: "\rString in size 2',

    appliedParagraphStyle: styleFormat2

    };

    }

    But until now I did not get a new paragraph. When you look at the IDMLs, you can see that InDesign adds a new paragraph inside the cell, while my code remains in the same paragraph.

    Here the IDML result when I do in InDesign:

    "< cell auto ="ue0ie4i0"Name =" "0:0" RowSpan = "1" ColumnSpan = "1" AppliedCellStyle = "CellStyle / $ID / [no]" AppliedCellStylePriority = "0" >

    < ParagraphStyleRange AppliedParagraphStyle = "ParagraphStyle/Format1" >

    < CharacterStyleRange AppliedCharacterStyle = "CharacterStyle / $ID / [no style character]" >

    < content > string to Format 1 < / content >

    < Br / >

    < / CharacterStyleRange >

    < / ParagraphStyleRange >

    < ParagraphStyleRange AppliedParagraphStyle = "ParagraphStyle/Format2" >

    < CharacterStyleRange AppliedCharacterStyle = "CharacterStyle / $ID / [no style character]" >

    < content > string to Format 2 < / content >

    < / CharacterStyleRange >

    < / ParagraphStyleRange >

    < / cell >

    And here is that when I use the script:

    "< cell auto ="ue0ie4i0"Name =" "0:0" RowSpan = "1" ColumnSpan = "1" AppliedCellStyle = "CellStyle / $ID / [no]" AppliedCellStylePriority = "0" >

    < ParagraphStyleRange AppliedParagraphStyle = "ParagraphStyle/Format2" >

    < CharacterStyleRange AppliedCharacterStyle = "CharacterStyle / $ID / [no style character]" >

    < content > string to Format 1 < / content >

    < Br / >

    < content > string to Format 2 < / content >

    < / CharacterStyleRange >

    < / ParagraphStyleRange >

    < / cell >

    It is therefore quite clear my script is not adding a new paragraph. Any ideas how to get a new paragraph so I can use more than one paragraph style?

    I don't have test nore debug your code, but I suggest you another method to apply the content and style of two paragraphs. Do not use a with statement.

    What is your version of InDesign?

    Example:

    // Add new document:
    var doc = app.documents.add();
    // Add two paragraph styles:
    var paraStyle1 = doc.paragraphStyles.add({name : "ParaStyle-1" , pointSize : 20});
    var paraStyle2 = doc.paragraphStyles.add({name : "ParaStyle-2" , pointSize : 15});
    
    // Add a new text frame (default is on page 1):
    var newTextFrame = doc.textFrames.add();
    newTextFrame.geometricBounds = [0,0,"150mm","150mm"];
    
    // Add a table to this text frame:
    var table = newTextFrame.tables.add
    (
        {
            bodyRowCount : 4 ,
            columnCount : 3 ,
            width : "150mm"
        }
    
    );
    
    // Assign the contents as array:
    // The fisrt and only entry in this array will give the first cell its contents:
    table.contents =
    [
        "Paragraph 1"+"\r"+"Paragraph 2"
    ]
    
    // Assign the formatting of the two paragraphs:
    table.cells[0].paragraphs[0].appliedParagraphStyle = paraStyle1;
    table.cells[0].paragraphs[1].appliedParagraphStyle = paraStyle2;
    

    Strategic outcome with InDesign CS6 Mac OS x 10.6.8 v8.1.0:

    Hope, that helps.
    Uwe

  • [AS] [CS6] Apply different styles in the context of a text

    Hello

    Currently I have an AppleScript script to fill a block of plain text with a series of chains:

    say MyTextFrame to define (content of the history of the mother) to MyText1 & MyText2 & MyText3 & MyText4

    I would like to apply a different style (MyStyle1 to MyStyle4) for each of these channels (MyText1 to MyText4).

    Precision: MyTextI strings can contain a word or a paragraph or more, so I can't apply a style to a paragraph, for example.

    Thomas

    See the syntax below

    Please note that, while the js elements begin a 0 as start at 1, so you will have to set that in the script by Uwe

    Tell application "Adobe InDesign CS6"

    Set myDocument to the active document

    page 1 of myDocument, myPage value

    myTextFrame value framework text 1 of myPage

    tell the parents of myTextFrame

    Reference value character myText 1-character - 2 of paragraph 1 of the text object

    say myText

    apply the character style with the character style "myCharStyle" of myDocument

    tell the end

    tell the end

    tell the end

    look at examples in manual https://www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/InDesignScripting/InD esign-ScriptingGuide - AS.pdf

    A very useful guide indeed

    Trevor

  • GREP for changing the style of paragraphs ending with '='

    Hi, I work with a giant list of the names and dates of graduation. Each line ends with a space and an equal sign must have a special paragraph applied to her style. Is it possible to design a "find/replace" for this, instead of manually? I can't understand what would work the GREP search string - I've never worked with him before, and I can't find anything in the lists of the metacharacters that would do the trick. Any ideas?

    In find it on the field just type = $ ( means hit the bar to type a space). The $ at the end means the end of a paragraph, so he could find no instance anywere elsewhere in a paragraph, which is the only reason why you have to GREP for that instead of a search of plain text.

    Set the paragraph style that you need in the form of the change.

    It works only if it IS indeed the end of a paragraph, however. If you have several lines in the same paragraph that ends with =, or more text in the paragraph after the =, you need to show us the structure. Don't forget that the paragraphs can have style single paragraph, applied to the whole paragraph. If you need several styles in the same paragraph, you need to use character styles, which can be applied as nested styles, line styles and GREP styles, or manually, depending on the structure of the text, you have to work with.

  • Apply the style nested up to one of several characters

    I d-i-d try this old College, but maybe I don't know the right place or I am limited in nested Style in style GREP.

    I have a number any unpredictable predictable characters I want to apply a style CH "up to".

    Example 1: The Club of InDesign in the Future meeting, 15:30: here are some examples of text...  Here is some sample text...  Here are some examples of text--in this case, "up to" colon
    Example 2: The Club of InDesign in the Future meeting, 15:30 - here is an example of text...  Here is some sample text...  Here are some examples of text--in this case, "until" space hyphen

    Example 3: The Club of InDesign in the Future meeting, 15:30 - here is an example of text...  Here is some sample text...  Here are some examples of text--in this case, "until" space hyphen hyphen

    Example 4: The Club of InDesign in the Future meeting, 15:30, here is an example of text...  Here is some sample text...  Here is some example text--in this case, "up to" any character (comma) [of course, there is an argument in this one]

    There are 5-6. predictable samples.  But nested Styles stacked on each other tends to "BOLD" of the whole paragraph.  A js script would be more applicable here, or do you think the GREP style work?  I missed (even with my books on GREP) to any type of nail model.

    How do you tell the difference between the first and the second comma in the meeting, 15:30? They are all two followed by a space. PM maybe a clue? Then ^. +? pm\s [:-]-? might work.

    Peter

  • text styles and paragraph autoflowing

    Hello forumers

    If I do my own paragraph style and the want to add what it all my pages, how can be done at the same time?

    Im trying to do, but I can only apply the paragrahp style to a 2page spread at once, not entire pages of the page 1-page 30

    Thank you.

    Styles are applied to the text, not pages. Don't we cover last week?

    You can select all the text in any subject, even if it is in excess or on another Board, then apply your style. You'll have to make each story independently, however. For new features, select the style with no selected text and it will become the default.

  • Several styles of paragraph in a cell?

    Maybe I'm missing something real simple, but I'm having a bit of a problem with the styles.  What I'm trying to do, this is the name of a tool in the style of a paragraph and description (separated from the name by '-') in a different paragraph style - all in the same cell in a table.  Instead, when I try to change the styles he changes all the text in the cell.  Even if I come back and highlight the name of the tool and replace it with a different style description, it changes everything including what is not highlighted text.  If anyone has a solution I would be very happy!

    I think what you want to do is nesting of character styles. Paragraph styles will apply to all text before a hard return. Nest a different character style by using your "-" characters.

Maybe you are looking for

  • Firefox remembers the story-why?

    Hi guys! My firefox does remember any history at all. Of course, the privacy settings say: "don't forget history." Everything else (bookmarks and this work very well.) I did a "reset firefox" twice; no change. There is an article of a person with sim

  • How can we restrict a Web sites in firefox?

    I want restricted some sites so that I won't be able to open that Web sites.

  • Renaming of files using the batch file or other means of batch

    I have several hundred .pdf files and would like rename them by removing the first 10 characters of each file name. Is there a .bat file or an easy way to do this? Thank you very much. All the first 10 characters of each file name are the same.

  • FilePicker fileSelected() signal do not work

    When I select a file in FilePicker, it must issue the signal of fileSelected() with QStringList to the URI of the file, but this QStringList is empty. FilePicker::selectedFiles() public method doesn't work either. How to know the files selected in Fi

  • Is it still possible to buy Photoshop CS6 Adobe?

    A client of mind is adamant that he will not buy the Plan of Adobe photography or any other form of software subscription.   I told that Adobe still offers Photoshop CS6 aging, as an alternative to a subscription, but I can find is no longer on their