Find start text index from paragraph style?

hi,
    In my project,i have paragraph style name,i need to find out that paragraph start and end index positon ?
pls,anyone help me?
thanks,
screen410099

Hi Saud,
Try the below script.
var activeDoc = app.activeDocument;
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.appliedParagraphStyle = "XXXX";//Give your paragraph Style name here
var foundRefList = activeDoc.findGrep();
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
var myCount =0;
var foundListLength = foundRefList.length;
for (var j = 0; j<foundListLength; j++){
    var myParas = foundRefList[j].paragraphs;
    var myParaLength = myParas.length;
    for (var i = 0; i<myParaLength; i++){
        var myText  = myParas[i].texts[0];
        app.select(myText);
        var myId = j+"_"+(i+1);
        var myHyperlinkCitDestination = activeDoc.hyperlinkTextDestinations.add(myText, {name: myId});
        myCount++;
    app.select(NothingEnum.nothing);
    alert("Process Completed\n"+myCount+" destinations added");
p.s: I've not tested it, please check this at your end and let me know.
~Green4ever

Similar Messages

  • Find.text Then apply Paragraph.Style

    Hi Everyone,
    Is that possible we find the text then apply the paragraph style every find text.
    We find [CN] then apply paragraph style "Chap_Num", Find next  [CT] apply PS "Chap_TTL" Find next [COX1] apply PS "Chap_Para".
    Any trick find and apply para style one time.
    Thank you! I appreciate your help and explanation Adv.

    @s_ashok – you'll find the right methods and properties in the CHM file for InDesign CS2 at:
    http://www.jongware.com/idjshelp.html
    Just a few hints:
    InDesign CS2 does not support GREP search/replace, so every line in your code that points to GREP does not work.
    Further: "app.findTextPreferences" and "app.changeTextPreferences" were "app.findPreferences" and "app.changePreferences" in InDesign CS2. And then there were no "findChangeTextOptions" or any counterpart for that in CS2…
    That should get you running…
    I have no InDesign CS2 installed to debug, so this is all I can say…
    Uwe

  • Find & Replace the text and apply paragraph style in indesign CS2.

    Hai below script are working in cs4 - cs5.5. i need to run the script in indesign cs2.
    can you please help.
    Main();
    function Main() {
        var foundItem;  
        var doc = app.activeDocument;
        //app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
    app.findTextPreferences.findWhat = "^p";
           //app.findTextPreferences.appliedParagraphStyle = "head";
        var foundItems = doc.findText();
        for (var i = 0; i < foundItems.length; i++) {
            foundItem = foundItems[i];
            foundItem.applyParagraphStyle(doc.paragraphStyles.item("content body indent"), false);
         app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
         var myDocument = app.activeDocument;
    //Clear the find/change text preferences.
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeTextOptions.caseSensitive = false;
    app.findChangeTextOptions.includeFootnotes = false;
    app.findChangeTextOptions.includeHiddenLayers = false;
    app.findChangeTextOptions.includeLockedLayersForFind = false;
    app.findChangeTextOptions.includeLockedStoriesForFind = false;
    app.findChangeTextOptions.includeMasterPages = false;
    app.findChangeTextOptions.wholeWord = false;
    //Search the document for the string "copy" and change it to "text".
    app.findTextPreferences.findWhat = "^p";
    app.changeTextPreferences.changeTo = "^p";
    myDocument.changeText();
    //Clear the find/change text preferences after the search.
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;
    abc();
    function abc() {
        var foundItem;  
        var doc = app.activeDocument;
        //app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
    app.findTextPreferences.findWhat = "*";
           //app.findTextPreferences.appliedParagraphStyle = "head";
        var foundItems = doc.findText();
        for (var i = 0; i < foundItems.length; i++) {
            foundItem = foundItems[i];
            foundItem.applyParagraphStyle(doc.paragraphStyles.item("RealEstate"), false);
         app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
         var myDocument = app.activeDocument;
    //Clear the find/change text preferences.
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeTextOptions.caseSensitive = false;
    app.findChangeTextOptions.includeFootnotes = false;
    app.findChangeTextOptions.includeHiddenLayers = false;
    app.findChangeTextOptions.includeLockedLayersForFind = false;
    app.findChangeTextOptions.includeLockedStoriesForFind = false;
    app.findChangeTextOptions.includeMasterPages = false;
    app.findChangeTextOptions.wholeWord = false;
    //Search the document for the string "copy" and change it to "text".
    app.findTextPreferences.findWhat = "*";
    app.changeTextPreferences.changeTo = "";
    myDocument.changeText();
    //Clear the find/change text preferences after the search.
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;
    ab();
    function ab () {
        var foundItem;  
        var doc = app.activeDocument;
        app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
        app.findTextPreferences.findWhat = " ^ ";
    app.changeTextPreferences.changeTo = " ";  
        //app.findTextPreferences.appliedParagraphStyle = "head";
        var foundItems = doc.findText();
        for (var i = 0; i < foundItems.length; i++) {
            foundItem = foundItems[i];
            foundItem.applyParagraphStyle(doc.paragraphStyles.item("day"), false);
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
         var myDocument = app.activeDocument;
    //Clear the find/change text preferences.
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeTextOptions.caseSensitive = false;
    app.findChangeTextOptions.includeFootnotes = false;
    app.findChangeTextOptions.includeHiddenLayers = false;
    app.findChangeTextOptions.includeLockedLayersForFind = false;
    app.findChangeTextOptions.includeLockedStoriesForFind = false;
    app.findChangeTextOptions.includeMasterPages = false;
    app.findChangeTextOptions.wholeWord = false;
    //Search the document for the string "copy" and change it to "text".
    app.findTextPreferences.findWhat = "^";
    app.changeTextPreferences.changeTo = "";
    myDocument.changeText();
    //Clear the find/change text preferences after the search.
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;

    @s_ashok – you'll find the right methods and properties in the CHM file for InDesign CS2 at:
    http://www.jongware.com/idjshelp.html
    Just a few hints:
    InDesign CS2 does not support GREP search/replace, so every line in your code that points to GREP does not work.
    Further: "app.findTextPreferences" and "app.changeTextPreferences" were "app.findPreferences" and "app.changePreferences" in InDesign CS2. And then there were no "findChangeTextOptions" or any counterpart for that in CS2…
    That should get you running…
    I have no InDesign CS2 installed to debug, so this is all I can say…
    Uwe

  • Create Oracle Text Index from Java via JDBC

    Hi, I have a question relevant to creation of the Text Index in Oracle Text via Java JDBC.
    In Java I create client application and I connect to remote Oracle server. (there is Oracle
    10g Enterprise Edition 10.2.0.3.0 on Debian Linux OS). In Java I create query:
    CREATE INDEX index_name ON source_tab(text) indextype is ctxsys.context
    parameters('datastore ctxsys.file_datastore filter ctxsys.null_filter');
    and I start it by:
    PreparedStatement stmt = db.prepareStatement(query);
    ResultSet rs = stmt.executeQuery();
    There is problem that Text Index is created empty and when I write out error log then:
    DRG-11513: unable to open or write to file "path"
    I have on my computer Oracle XE 10g (Windows XP OS) here this application in Java functions
    without problems. Without problems it´s with that same query in SQLPlus when I connect at
    this remote Oracle server via PuTTY.
    Do you know anybody where could be error? Or at worst case where find I more detailed
    manual about JDBC Oracle mainly possible errors and problems with compatibility?

    Does it work if you don't use "file_datastore"?
    Eg. try the following in sqlplus:
    create table t (text varchar2(2000));
    insert into t values ('hello world');
    create index ti on t(text) indextype is ctxsys.context;
    select * from t where contains (text, 'hello') > 0;
    Then drop the index ti and try the same "create index" through JDBC. Does that work?
    If so, then we have some kind of issue with the file_datastore. I assume you are aware that the file will be read by the SERVER, not from the client?
    So if your database resides on a Linux box, but you are calling from a Java program on a windows PC, the file names in source_tab(text) must be in Linux format, and must refer to files which are available on the Linux server (and readable by the owner of the Oracle database process).
    So /home/me/file.txt might work, but C:\Documents\file.txt will not.

  • CS5: Hyperlink to text anchor from character style?

    Is it possible to script the following:
    A text has several occurances of the same string, e.g. 'A10'. One is marked with a character style 'Anchor' and the others are marked with a character style 'Link'. The idea is to create text anchors from the 'Anchor' style and then find every occurrence of the character style 'Link' and create a hyperlink to the matching anchor.
    I've managed to find a script that creates text anchors from a character style 'Anchor'. Can someone offer some suggestions on how to do script creating the links?
    // Written by Kasyan Servetsky
    // March 13, 2011
    // http://www.kasyan.ho.com.ua
    // e-mail: [email protected]
    //======================================================================================== =================================
    if (app.documents.length == 0) ErrorExit("Please open a document and try again.");
    const gScriptName = "Create Text Anchors";
    const gScriptVersion = "1.0";
    var gDoc = app.activeDocument;
    if (!gDoc.characterStyles.item("Anchor").isValid) ErrorExit("Character style \"Anchor\" doesn't exist.");
    CreateDestinations();
    //======================================================== FUNCTIONS  =====================================================
    function CreateDestinations() {
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
        app.findGrepPreferences.findWhat = ".+";
        app.findGrepPreferences.appliedCharacterStyle = gDoc.characterStyles.item("Anchor");
        var finds = gDoc.findGrep();
        var destCounter = 0;
        for ( var j = finds.length-1; j >= 0; j-- ) {
            var found = finds[j];
            try {
                if (!gDoc.hyperlinkTextDestinations.itemByName(found.contents).isValid) {
                    var hypTextDest = gDoc.hyperlinkTextDestinations.add(found);
                    hypTextDest.name = found.contents;
                    destCounter++;
            catch(e) {}
        if (destCounter == 0) {
            alert("No text anchors have been created.", gScriptName + " - " + gScriptVersion);
        else if (destCounter == 1) {
            alert("One text anchor has been created.", gScriptName + " - " + gScriptVersion);
        else if (destCounter > 1) {
            alert(destCounter  + " text anchors have been created.", gScriptName + " - " + gScriptVersion);
    function ErrorExit(error, icon) {
        alert(error, gScriptName + " - " + gScriptVersion, icon);
        exit();

    Hi,
    The way is:
    create hyperlinkTextDestination;
    create hyperlinkTextSources;
    create hyperlinks using one destination and various sources;
    so:
    // to create hyperlinks alike:    one destination==>many sources
    // destination is the 1st occurrence of text with charStyle "anchor" applied
    // sources are each occurrences of text with charStyle "link" applied
    var mDoc = app.activeDocument;
    app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
    app.findTextPreferences.appliedCharacterStyle = mDoc.characterStyles.item("anchor");
    var
         mAnchor = mDoc.findText()[0],
         mDest;
    if (mAnchor) mDest = mDoc.hyperlinkTextDestinations.add(mAnchor,{name: mAnchor.words[0].contents});
    else {alert ("no anchor found"); exit(); }
    app.findTextPreferences.appliedCharacterStyle = mDoc.characterStyles.item("link");
    var
         mSource = mDoc.findText(),
         len = mSource.length,
         currSource, currHyper;
    if (!len) {alert ("no link found"); exit(); }
    while (len-->0) {
         currSource = mDoc.hyperlinkTextSources.add(mSource[len],{name: "sourceLink_" + len});
         currHyper = mDoc.hyperlinks.add(currSource, mDest, {name: "mHyperlink_" + mDest.name + "_" + len});
    app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
    Jarek

  • From paragraph Style to "New Hyperlink Destination"

    Dear InDesign Experts
    Please help me to find a way or Script to add all headings of specific paragraph style to "New Hyperlink Destination....(Text Anchor)"
    and ... is there any automation for such a task?
    Thank you in advance

    Hi Saud,
    Try the below script.
    var activeDoc = app.activeDocument;
        app.findGrepPreferences = NothingEnum.nothing;
        app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.appliedParagraphStyle = "XXXX";//Give your paragraph Style name here
    var foundRefList = activeDoc.findGrep();
        app.findGrepPreferences = NothingEnum.nothing;
        app.changeGrepPreferences = NothingEnum.nothing;
    var myCount =0;
    var foundListLength = foundRefList.length;
    for (var j = 0; j<foundListLength; j++){
        var myParas = foundRefList[j].paragraphs;
        var myParaLength = myParas.length;
        for (var i = 0; i<myParaLength; i++){
            var myText  = myParas[i].texts[0];
            app.select(myText);
            var myId = j+"_"+(i+1);
            var myHyperlinkCitDestination = activeDoc.hyperlinkTextDestinations.add(myText, {name: myId});
            myCount++;
        app.select(NothingEnum.nothing);
        alert("Process Completed\n"+myCount+" destinations added");
    p.s: I've not tested it, please check this at your end and let me know.
    ~Green4ever

  • CS4 creating hyperlinks in TOC from paragraph style sheet

    Hi all
    Does anyone know if it's possible for a script to find all instances of text in a named paragraph style  and then link each instance to the corresponding entry in a modified TOC?
    The workflow is for a 800-item catalogue created in CS4. At the moment, the title for each entry is set in a dedicated paragraph style; once all entries are signed off, I generate a TOC listing all the items. All very straightforward.
    My client now wants an interactive PDF so that clicking on any item in the TOC will take him automatically to the relevant page in the catalogue. I want to avoid having to generate those hyperlinks manually… I know very little about scripting but I do know this is exactly the sort of thing that should be possible:
    – find first instance of text in Para Style 1
    – create hyperlink named with that text
    – link this to corresponding text in Para Style 2
    – repeat for all instances of text in Para Style 1.
    But I also know that the hyperlink/cross-reference function can be a little counter-intuitive and I don't know whether I'm asking for the moon on a stick.
    Thanks!

    There's an excellent script* called LiveTOC which does exactly what you're asking for. It allows you to turn all your TOC entries into hyperlinks for PDF export.
    Check it out: http://www.freelancebookdesign.com/scripts/live-toc
    Ariel
    * which happens to have been written by me

  • [JS IDCS5] Create tags from paragraph styles

    Hello,
    I would like to iterating through al the paragraph styles within a document to create there tags from. The tags should have the same name as the paragraph styles. Is that possible and how?
    Regards, Sjoerd

    Hi Phil,
    Absolute beginer here. The script creates tags for the styles outside groups, but for some reason it doesn't create the tags out of the Paragraph Styles in folders.
    I enabled the line below and tried to change the "myPStyle"  for "myAllPStyle" in the following lines, but still nothing. Gives error when reaches the line myDoc.changeText();
    Any hint?
    var myAllPStyle = myDoc.allParagraphStyles; //if you want this enable a line all the folder paragraph styles also consider
    for (i=2; i<myAllPStyle.length; i++){
         var myAllPStyleName = myAllPStyle[i];
         //alert(myPStyleName.name);
         try{
              var myXml = myDoc.xmlTags.add(String(myAllPStyleName.name));
              }catch(e){}
         app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
         app.findTextPreferences.appliedParagraphStyle = myAllPStyleName;
         app.changeTextPreferences.markupTag=myAllPStyle[i].name;
         myDoc.changeText();
         app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
    Also, how can I make it Map the tags with the PStyles by name after with the script?
    Thanks so much
    Hector

  • Exporting to filename from paragraph style

    I have a 80 page indesign file.  I would like to export to single page pdfs, with filenames based off a paragraph style on each page.
    Is this possible?  I have no background or experience with scripting.  Any help would be much appreciated.
    Thanks
    Derek

    The link you sent me was about Applescript. But I looked it up in the Javascript reference and this seems to work.
    You need to make three changes:
    Line 6: Change test to the name of your paragraph style.
    Line 15: Change [Smallest File Size] to the export preference you like to use, so you get resolution, bleed etc correct.
    Line 19: Change export path, I exported mine to my root, my harddrive, if you are on a pc "/c/cookbook/" + pdf_name + ".pdf" might be a better path.
    for(var p = 0; p < app.documents[0].pages.length; p++) {
         var frames = app.documents[0].pages[p].textFrames;
         var pdf_name = null;
         for(var i = 0; i < frames.length; i++) {
              if(frames[i].paragraphs[0].appliedParagraphStyle.name == 'test') {
                   pdf_name = frames[i].paragraphs[0].contents;
                   break;
         if(pdf_name != null) {
              app.pdfExportPreferences.pageRange = app.documents[0].pages[p].name;
              var export_preset = app.pdfExportPresets.item("[Smallest File Size]");
              app.documents[0].exportFile(
                   ExportFormat.pdfType,
                   File("/" + pdf_name + ".pdf"),
                   false,
                   export_preset

  • How do you start new line in paragraph style?

    New trial user and can't figure out why a seemingly simple operation doesn't work..
    How do you start a new line in a paragraph block?  When I hit the enter key, it just returns to the front of the same line, overwriting the same line over and over again.
    1. Clicked Text tool.
    2. Dragged out a paragraph block.
    3. Started typing and noticed that when it reached the end of the paragraph block, it just wrapped to the beginning.
    Frustrated so could use some help.

    …but also make sure that the No Break option in the dropdown menu (triangle at upper right corner) of the Character Panel is UNchecked:

  • Is it a way cut and paste text and have paragraph style it

    Can I cut and paste from a word document in have indesign style it like below. Or do I have to one by one style it like below.
    Laura Benner
    Director of Human Resources
    Tiffany & Co.
    600 Madison Avenue
    New York, NY 10022
    (212) 755-8000

    You can use Apply Style, then next style to format each contact all at once. If all of the address info is exactly 4 lines long, you could have the phone number in a separate style, with Name as its next style. You could then style the whole list in one motion.

  • Where to find "Partner Text", field from inside transaction IW33?

    Hi all!
    Inside the transaction IW33, there is a folder/screen Partner. Inside this Partner screen it is a field u201CNameu201D. This is the third line from left. Do anyone now where in the database the data inside the field u201CNameu201D is been read? If I look into the technical details, I do only se the structure name. And that is DIADR-NAME_LIST. I do want to find out where this data has been read from.

    Hi,
    In Tcode: ME42, enter the request for quotation number (RFQ) and press enter. System will take you to 'Item Overview' screen. From menu select 'Header' -- 'Details' or press F6. Then the system will take you to 'Header screen' there you can see the 'company code' after RFQ number field.
    Or
    Directly from Tcode: ME42, enter the request for quotation number,then from menu select 'Header' -- details. Here you can have the company code field.
    The data for company here too will get updated in table and field EKKO-BUKRS.
    Hope this helps.
    Thanks,
    Viswanath

  • How to delte empty Style Group from paragraph style palette

    Hi Guys,
    I want to delete my empty paragraphStyleGroups folder that are Style Group 1and Style Group 3 (see pic) from my palette.
    I need a js code for this task.
    I have created script but it deletes all the Style group from my panel.
    Here is the script:
    myDoc=app.activeDocument;
    myStyleGroup=myDoc.paragraphStyleGroups;
    for(p=0;p<myStyleGroup.length;p++)
    myStyleGroup[p].remove();
    Please suggest!
    Chang

    You are awesome man.
    It is working as I need. Thanks again Kasyan.
    Regards,
    Chang

  • FIND/CHANGE - Applying Paragraph Style

    Hello,
    I used FIND/CHANGE to apply my paragraph style and when I apply the paragraph style... it applies the style to the entire line.
    For example,
    A. #70712       resulted to         A. #70712
    I only wanted the "#70712" to be changed to my style. I used the GREP search and entered #.+ and then I choose the paragraph style I want and clicked change all. The problem is that it changed all the text on that line and applied the paragraph style.
    Please help. Thank you very much.

    graphicsoc wrote:
    Hello,
    I used FIND/CHANGE to apply my paragraph style and when I apply the paragraph style... it applies the style to the entire line.
    For example,
    A. #70712       resulted to         A. #70712
    I only wanted the "#70712" to be changed to my style. I used the GREP search and entered #.+ and then I choose the paragraph style I want and clicked change all. The problem is that it changed all the text on that line and applied the paragraph style.
    Please help. Thank you very much.
    If I understand your request correctly:
    If your paragraph style uses a numbered list to create the "A." and the remainder of the paragraph consists of only "# 70712" that you type in manually (or place from an existing file), I believe that you you don't need GREP. You can format the auto-numbered list differently from the remainder of its paragraph, by specifying a character style for the number portion.
    To extract only the non-numbered portion of an auto-numbered paragraph, for a TOC, in the Table of Contents dialog box, open the bottom part by clicking More Options if necessary, and in the Numbered Paragraphs pull-down menu, select Exclude Numbers.
    Read more about Table of Contents in Help, and/or with a Google search for terms like "InDesign table of contents numbered list exclude numbers" without quotes.
    If you need additional special formatting "tricks" in the source paragraphs, or in the TOC entry paragraphs, look into Nested Styles and GREP
    Styles in Help or Google searches.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • Paragraph style - Drop shadow on text

    Hi,
    I cannot find out how to apply a drop shadow to text in a paragraph style.
    It looks like drop shadow can only be applied to Object style.
    And object must be selected with selection tool. My text box goes up to 30 pages!
    I don't want all the text with shadow.
    Any help or cue will be appreciated.
    thanks

    Drop shadows can only be applied to all text within a Frame. You will need to separate the paragarphs you want a drop shadow from and Anchor those within the text.
    http://help.adobe.com/en_US/indesign/cs/using/WSa285fff53dea4f8617383751001ea8cb3f-6c43a.h tml

Maybe you are looking for