Character in front of text set with certain paragraph style

Hello

I am a beginner in the art of scriptning InDesign, and I have an issue that I know can be solved in javascript in InDesign.

It is InDesign CS5.5.

I just want to insert an "S" in front of all the paragraphs with the paragraph style "Silkeborg".

I have struggled a little with it and did this:

var doc = app.activeDocument;
var intSelect = app.selection.length;
var arrSelection = [];
arrSelection = app.selection[0];
app.selection[0].insertionPoints[0].contents = "S ";

But this insert in paragraph 1.

Hi Jimmy,.

Here's a quick and dirty script to your problem solution. The code could be nicer, but it gives you an idea on what to do:

1. loop through all the stories, and then through all paragraphs in each story

2. determine if a paragraph has the style applied "Silkeborg".

3 If yes then select it and insert "S" before:

var oDoc = app.activeDocument;

//First loop through all stories then through all paragraphs in each story
for(n=0; n< oDoc.stories.length;n++){
    for(i=0;i 
         

Tags: InDesign

Similar Questions

  • Scripts to insert metadata automatically to the document with the paragraph style

    Hello

    I am trying to find a way to insert automatically the metadata in my document through paragraph style in indesign cs5.5.

    It comes to myDocument title, author name , and description of myDocument.

    Is there anyone who can help me with this project?

    Thank you.

    Place the script at the following location: C:\Program Files\Adobe\Adobe InDesign CS6\Scripts\startup scripts

    If you close it document the script will automatically put the metadata in your indesign file (use ctrl + w or menu-> file-> the option close to close the file)

    Code:

    #targetengine session

    If you want to test the script for your active document, comment on the threshold of another, copy the script to your startup folder

    app.menuActions.itemByName ("Close").eventListeners.add ("beforeInvoke", function()

    {

    myDoc var = app.activeDocument;

    var docTitleText ="";

    var docDescripText ="";

    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findGrepPreferences.findWhat = '. +';

    found = app.activeDocument.findGrep (true);

    for (j = found.length - 1; j > = 0; j-)

    {

    var foundText = .silence found [j];

    You can set several style of paragraph for the title of the Document

    if(found[j].texts[0].appliedParagraphStyle.Name=="docTitle1")

    {

    docTitleText = found .silence [j];

    }

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docTitle2")

    {

    docTitleText = docTitleText + "" + found .silence [j];

    }

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docTitle3")

    {

    docTitleText = docTitleText + "" + found .silence [j];

    }

    You can define several paragraph of Description of Document style

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docDescription1")

    {

    docDescripText = found .silence [j];

    }

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docDescription2")

    {

    docDescripText = docDescripText + "" + found .silence [j];

    }

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docDescription3")

    {

    docDescripText = docDescripText + "" + found .silence [j];

    }

    }

    with (myDoc.metadataPreferences) {}

    author = "My Name";

    documentTitle = docTitleText;

    Description = docDescripText;

    }

    });

    Vandy

  • Text does not accept paragraph styles

    I changed the paragraph styles in a document that I did not create. Sometimes after I change the style, the text will not change. In the paragraph style palette, it seems that the text has received the style and does not show a sign indicating a replacement option.

    I tried to create a new barn and set the text of this new style. The text will not just change. What could be going on here?

    Thank you!

    Check the nested styles.

    You can quickly verify this by placing the text cursor in the text and checking the character styles. There should be "carriage return" symbol and a character at the base of the Panel style showing you what the template is applied.

    See at the bottom of the ice Panel

  • Impossible to format document with several paragraph styles and notes

    I'm working on a document where I have several text boxes on the same page. The text boxes reflect implemented different paragraph styles so that they will autopopulate in my table of contents. However, I need to add notes to this document. I find that the notes are at the end of the text box to which they apply to, and if I had to put a note in two different text boxes on the same page, both start at 1.

    Is it possible to manage notes in several text boxes? Or, if not, is it possible that I can attach my table of contents for the styles of characters instead of paragraph styles?

    Thank you!

    Looking at your screen shot in post #2, I see no reason to require individual images. You can manage every bit of this formatting in a unique setting using the styles section to control alignment, and dashes.

  • Problem with the paragraph style "paragraph NET."

    I have a paragraph style with a paragraph in her net. There is something that I don't know what to do about it.

    When I hit 'back' to move a paragraph with this style, it leaves a rule in its wake. Here is a screenshot:

    Screen shot 2010-08-15 at 9.58.04 AM.png

    The title "Introduction" has a paragraph with a net of applied paragraph style. I put the cursor just before the word 'Introduction', press return, and it leaves a line in the previous line. Weird huh?

    Don't use not paragraph refers ALWAYS to put in place a space between paragraphs. Use the space before or after the space in the paragraph in withdrawal and spacing Style.

    If it's the beginning of a block of text and you want it to appear lower in the frame adjust them the object > text frame Options and give him a Medallion from the top. OR this way http://indesignsecrets.com/push-down-the-first-line-of-text.php

    The line of paragraph appears is because when you press back the paragraph he the same paragraph style, ergo the same paragraph style. To get rid of it, change the paragraph style from the paragraph above to something else.

    But you shouldn't really use back to add a space between paragraphs. Space before and after the space are much more effective.

    http://blogs.Adobe.com/indesigndocs/2009/05/5_typing_rules.html

    http://creativementor.com.au/adding-space-after-paragraphs

    http://help.Adobe.com/en_US/InDesign/6.0/WSa285fff53dea4f8617383751001ea8cb3f-6dcea.html

  • Export InDesign text in a text file with paragraph styles

    Hello

    is it possible to export text in InDesign in a text file with included paragraph styles?

    I want not only to include the formatting of the text that I must have still all paragraph styles applied to the text after the export.

    Thank you

    With the text tool in the ready to type text block. Choose file > export > RTF (Rich Text Format)

    For all text to export text all images must be strung. If they don't you will have to do them individually.

    If you just want a select few paragraphs then highlight and choose then export > RTF

    Which can be opened in Word with all styles of tact.

    It is unclear with your workflow is here, can you elaborate on what you are trying to do?

  • Export to text file paragraph Style

    I have an InDesign document (several really), where I would like to extract all the text formatted with a paragraph style to create a glossary.

    I looked at ChangeCaseofSelectedStyle ExportAllStories and Dave Saunder trying to cobble something together (my scripting skills are next to zero). I had that day, now I'm stuck and errors.

    Any help?

    If ((app.documents.length! = 0) & & (app.selection.length! = 0)) {}
    myDoc = app.activeDocument;
    myStyles = myDoc.paragraphStyles;
    myStringList = myStyles.everyItem () .name;
    myExportFormatList = ['Text only', 'RTF', 'Text referenced InDesign'];

    myDialog = app.dialogs.add var ({name: "ExtractParagraphByStyle"})
    {with (MyDialog)}
    {with (dialogColumns.Add ())}
    with (dialogRows.add ()) {}
    with (dialogColumns.add ()) {}
    staticTexts.add ({staticLabel: "Style of paragraph :"});})
    }
    with (dialogColumns.add ()) {}
    myStyle = dropdowns.add({stringList:myStringList,selectedIndex:0,minWidth:133});)
    }
    }
    with (dialogRows.add ()) {}
    with (dialogColumns.add ()) {}
    staticTexts.add ({staticLabel: "export as :"}); "})
    }
    with (myExportFormatButtons = {radiobuttonGroups.add ())}
    radiobuttonControls.add ({staticLabel: "Text only", checkedState:true});})
    radiobuttonControls.add({staticLabel:"RTF"});)
    radiobuttonControls.add ({staticLabel: "InDesign tagged text"});
    }
    }
    }
    }


    myReturn = myDialog.show ();
    If (myReturn == true) {}
    Get the values of the dialog box.
    myExportFormat = myExportFormatButtons.selectedButton;
    myDialog.destroy;
    myFolder is Folder.selectDialog ("select a file");.
    If ((mondossier! = null) & & (app.activeDocument.stories.length! = 0)) {}
    myExtractParagraphByStyle (myExportFormat, myFolder);
    }
    }
    else {}
    () myDialog.destroy; s
    }
    }

    myExportStories function handles the export of the stories.
    myExportFormat is a number between 0-2, where 0 = text only, 1 = 3 = tagged text and rtf.
    myFolder is a reference to the folder in which you want to save your files.
    function myExtractParagraphByStyle (myExportFormat, myFolder) {}
    for (myCounter = 0; myCounter < app.activeDocument.stories.length; myCounter ++) {}
    monarticle = app.activeDocument.stories.item (myCounter);
    myID = myStory.id;
    {Switch (myExportFormat)}
    case 0:
    myFormat = ExportFormat.textType;
    myExtension = 'txt '.
    break;
    case 1:
    myFormat = ExportFormat.RTF;
    myExtension = ".rtf".
    break;
    case 2:
    myFormat = ExportFormat.taggedText;
    myExtension = 'txt '.
    break;
    }
    myFileName = "StoryID" + myID + myExtension;
    CheminMonFichier = myFolder + "/" + myFileName.
    myFile = new File (myFilePath);
    myStory.exportFile (myFormat, myFile);
    }
    }
    +++ Functions start here +++

    function errorExit (message) {}
    If (arguments.length > 0) {}
    If (app.version! = 3) {beep()} / / CS2 includes beep() function.
    Alert (message);
    }
    Exit(); CS ends with a beep; CS2 left silently.
    }

    The example script, export all the text to the file might give you some clues:

    ExportAllText.jsx
    An InDesign CS4 JavaScript
    //
    Export all the text in the active document with a single
    text file. To do this, the script will create a new document,
    combine the stories in the new document using export/import
    and then export the text into the new document.
    main();
    main() {} function
    mySetup();
    mySnippet();
    myTeardown();
    }
    function mySetup() {}
    myDocument var = app.documents.add ();
    myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
    myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
    myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
    myPage var = myDocument.pages.item (0);
    var myTextFrameA = myPage.textFrames.add ();
    myTextFrameA.geometricBounds = [72, 144, 72, 288];
    myTextFrameA.contents = 'This is story 1.';
    var myTextFrameB = myPage.textFrames.add ();
    myTextFrameB.geometricBounds = [72, 300, 228, 288];
    myTextFrameB.contents = 'This is the story 2.';
    var myTextFrameC = myPage.textFrames.add ();
    myTextFrameC.geometricBounds = [72, 444, 312, 288];
    myTextFrameC.contents = 'This is the story of 3.';
    }
    function mySnippet() {}
    //
    If (app.documents.length! = 0) {}
    If (. stories.length app.documents.item (0)! = 0) {}
    myExportAllText (app.documents.item (0) .name);
    }
    }
    //

    }
    function myTeardown() {}
    }
    //
    function myExportAllText (myDocumentName) {}
    var monarticle;

    File name for the exported text. Specify a valid file on your system path.
    var myFileName = "/ c/test.txt ';
    If you want to add a line of separation between the floors, myAddSeparator set to true.
    var myAddSeparator = true;
    var myNewDocument = app.documents.add ();
    var app.documents.item (myDocumentName) = myDocument;
    var myTextFrame = myNewDocument.pages.item (0).textFrames.add ({geometricBounds:myGetBounds (myNewDocument, myNewDocument.pages.item (0))});
    var myNewStory = myTextFrame.parentStory;
    for (myCounter = 0; myCounter)< mydocument.stories.length;="">
    monarticle = myDocument.stories.item (myCounter);
    Export the story as tagged text.
    myStory.exportFile (ExportFormat.taggedText, leader (myFileName));
    Import (place) the file at the end of the temporary history.
    myNewStory.insertionPoints.item(-1).place (File (myFileName));
    If the imported text does not end with a return, enter a return
    to keep the stories running together.
    If (myCounter! = myDocument.stories.length-1) {}
    If (myNewStory.characters.item(-1).contents! = '\r') {}
    myNewStory.insertionPoints.item(-1).contents = "\r";
    }
    if(myAddSeparator == true) {}
    myNewStory.insertionPoints.item(-1).contents = '-\r ";
    }
    }
    }
    myNewStory.exportFile (ExportFormat.taggedText, File("/c/test.txt));
    myNewDocument.close (SaveOptions.no);
    }
    //
    function myGetBounds (myDocument, myPage)}
    var myPageWidth = myDocument.documentPreferences.pageWidth;
    var myPageHeight = myDocument.documentPreferences.pageHeight
    if(MyPage.Side == PageSideOptions.LeftHand) {}
    var myPage.marginPreferences.left = myX2;
    myX1 = myPage.marginPreferences.right var;
    }
    else {}
    var myPage.marginPreferences.left = myX1;
    myX2 = myPage.marginPreferences.right var;
    }
    var myY1 = myPage.marginPreferences.top;
    myX2 var = myPageWidth - myX2;
    var myY2 = myPageHeight - myPage.marginPreferences.bottom;
    return [myX1, myY2, myY1, myX2];
    }

  • Find/replace, searching for specific text to replace it with the paragraph tag

    I tried to replace a string of text that I have at the beginning of a paragraph indicating a certain style of paragraph with this style of ID while eliminating the text string. For example, I put @IN1 at the beginning of a paragraph I want formatted with the paragraph of my ID IN1 style. However, when I have 'Search' @IN1 with no. find format and 'to' do not change (i.e. empty) with the paragraph style selected 1 selected under format change, it applies the paragraph style, but does not delete the text string @IN1. When you do a search/replace without the portion of paragraph desired syle, he removes the @IN1 correctly. It is a bug, or is there something I have to put in the change of area indicate no text? Thank you

    Using the GREP tab, find ^ (@IN1) (.) and replace with $2 and set the paragraph style in the change of format.

    The ^ beginning of paragraph says and the $2 is the second subexpression matching.

  • Change a setting, now paragraph Styles no character longer apply long Formats

    Hi all

    I use InDesign CS4 ver 6.0 on Mac OS 10.5.8.

    My document has loaded in her paragraph Styles. When I click on the text in my document, the corresponding paragraph Styles are highlighted in the paragraph Styles window. But the text is not formatted with character formatting that is associated with the paragraph Style.

    I took a glance at my character Styles window, and I see that, regardless of the selected paragraph Style, the text on the page is locked in a single character Style, substituting the selected paragraph Style.


    I've must have changed a parameter but do not know which. Someone has any advice on how to get to InDesign to apply the formatting of characters specified in paragraph Styles.

    Thanks in advance for your time.

    Given that the others don't tell you how to remove the default character style setting, I'll do it. With no active text cursor, will the character styles, and choose [none]. Do theat in a doc open to fix this doc. Do it with no docs open to fix all of the new files.

  • ID CC 2015 crashes as soon as I (try to) apply the paragraph style to the text.

    I work on a Mac Pro (mid-2009), OS X 10.10.4, 16 GB of RAM

    Original hard drive is 1 TB (where applications are installed), second drive (designated as working drive, and where all the work files are housed) is 2 TB.

    Currently subscribe to Adobe CC 2015, using InDesign with last update

    I have been working for several days on a long paper (paper) and have developed 12 paragraph styles, using two fonts - Garamond first Pro and Helvetica Neue LT and the document has facing pages.

    Yesterday, my client (the author) has asked all text flow on the odd pages, for illustrations on all pages, so I did all the text boxes thread directly downward of pages on the right (odd pages).

    The first three chapters were style before I changed the threading of text box. Now, when I open the document and begin to apply styles to paragraph for the rest of the text (nine more chapters, which automatically adopted the style of main text as soon as I stuck in the newly-threaded text boxes), ID crashes when I highlighted a section of text and click a paragraph style.

    I checked the permissions and preferences. The only thing I can think is from the document from scratch.

    Any other suggestions?

    Thread the text boxes only on odd pages cause the problem, since it does not have facing pages?

    Thank you.

    There could be corruption in the document.

    Save the document with IDML and reopen the IDML in InDesign.

  • written with a specific paragraph style can I transfer data

    In a document in each block of text, there are short texts written in the paragraph style

    the data in this paragraph style can transfer into a new text frame

    I'm doing this process with table of contents

    Is this possible with a script

    If possible specified in the data (1. and 7.), we can transfer the characters with grep

    image 021.JPG

    Try this,

    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = ".+";
    app.findGrepPreferences.appliedParagraphStyle = "test"; //mention your paragraph style name
    var mySearch = app.activeDocument.findGrep();
    myFrame = myDoc.textFrames.add ({geometricBounds:[".5in",".5in","5.5in","5.5in"]});//textframe will created in the first page of your InDesign document
    myFrame.insertionPoints[-1].contents = "CONTENTS\r";
    for(i=0; i
    

    Vandy

  • Paragraph styles changing all of the text, not only selected text

    Hello, I'm using CS5, InDesign, on a Mac and I'm having a terrible time applying my paragraph styles in the imported Word document. The main problem is when I select text to apply my paragraph style to, the style is applied to all the text in the thread of the text in InDesign. The solution I understood is to go in Word, cut and paste each section on Word, a new Word document and be sure to 'Paste special' and select 'text style' in Word. Then, I am able to apply for the different sections of text paragraph styles when it is imported into InDesign. The only problem is that all hyperlinks are removed and I must now enter and put them all by hand. It is well over 100 hyperlinks in this ebook. I spent 4 hours trying to solve this problem. There seems not to be a conflict of style when I import the Word document and I am sure no paragraph or character styles are selected when I put them the text. I changed the options "next style" in paragraph stlyes and which seems not helped either. This would be a matter of Word?

    That sounds to me like you have separte paragraphs, but have line breaks forced in the place where the paragraph breaks must be. You can check that by showing the nonprinting characters.

  • 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!

  • script to duplicate the standard paragraph style, and then change the size of the character point

    I want to create a script that will create a cascade of paragraph based on the style settings [standard paragraph] styles. My goal is to point size of each new paragraph style character as a percentage of the original [standard paragraph]. So if [standard paragraph] is 100% (point character size 10pt), the script would create a paragraph style called 120% ' that has a point size of character of 12 points. Then 133%, 140%, and on and on. I modified a script found on this forum to generate these new styles, but I don't know how to be based on the [standard paragraph]. Any help would be much appreciated, thanks in advance.

    current script:

    var doc = app.activeDocument,

    pStyle = ['100% ', '120% ', '133% '];

    for (var i = 0; i < pstyle.length; i ++)

    {

    If (pstyle [i] is "100 %")

    {

    doc.paragraphStyles.add ({name: pstyle [i], appliedFont: 'Deer', pointSize:10});})

    }

    ElseIf (pstyle [i] == "120 %")

    {

    doc.paragraphStyles.add ({name: pstyle [i], appliedFont: "Deer", pointSize:10 * 1,2})

    }

    ElseIf (pstyle [i] == "133 %")

    {

    doc.paragraphStyles.add ({name: pstyle [i], appliedFont: "Deer", pointSize:10 * 1.33333})

    }

    }

    Try this,

    var doc = app.activeDocument,
        pstyle = ["100%", "120%", "133%" ];
    
    for(var i =0;i
    

    Kind regards

    Cognet

  • Script for Indesign find paragraph style change at the table with the table style

    Hello

    I hope someone could help me with a script.

    I can tab with a paragraph style and I want to convert that to a table with a table style.

    Kind regards

    Patrick

    Yes

    My problem is solved

    Thank you very much.

    Patrick

Maybe you are looking for

  • 7520 photosmart all-in-in-one: blocks of color missing and streaked on diagnosis

    Hello My printer is no longer printing, currently indicating that there is a "printer failure". No other code. I ran through all the steps of troubleshooting online, but still it does not work. I ran a diagnostic print quality and the black 'block' i

  • Satellite P200 - 14 H no sound using external speakers

    Hi all I removed the speakers of the socket CAP and when I reinserted the card I did not all sounds.When the external speakers were connected on the laptop, I would get a low noise through the speakers of the laptop. Now its seems to be the opposite

  • Problem to create a recovery media for 442BL NB305

    Hello worldFirst of all, I apologize if responded to my question beforeI just buy Toshiba NB305 Netbook 442BLI created the flash recovery with the Toshiba recovery software but I don't want to keep my recovery only media on usb flash. As you know net

  • No light on the sound button

    Hey, I have Hp Pavillio 15-r077TX. For two days I was an isssue no light is displayed when I mute through his f6 key i.e.. Please help me Thank you!!

  • Uninstalling Norton to get microsoft security essentials

    I would use microsoft security essentials, but currently norton on my new processor.  The trial version is over so I am currently unprotected.  I don't understand how to go to add/remove programs and uninstall.  Last time, I uninstalled a program of