1 Reply Latest reply on Sep 23, 2010 4:15 AM by [Jongware]

    Select text between 2 bookmarks with Javascript

    indesign2000

      I'm trying to select text between 2 bookmarks. By now i have this:

       

         var doc = app.activeDocument;
         
          var bb = doc.bookmarks.firstItem();
          var be = bb.bookmarks.firstItem();
         
          bb.showBookmark();
          var fr = app.selection[0];
         
          be.showBookmark();
          var to = app.selection[0];
         
          bb.showBookmark();
         
          app.select(app.selection[0].parentStory.insertionPoints.itemByRange (fr.index, to.index));

       

      This code does not work if the bookmarks are on different pages.

       

      Any hint what have to go into the app.select() call ?

       

      What is the best way /reading to understand the DOM that uses app.select() ?

        • 1. Re: Select text between 2 bookmarks with Javascript
          [Jongware] Most Valuable Participant

          This code does not work if the bookmarks are on different pages.

           

          But it does, perfectly. I suspect there is another problem.

           

          What is the best way /reading to understand the DOM that uses app.select() ?

           

          app.select works just like manually selecting text. I think the underlying problem is that the text isn't just "on different pages", which is *not* a problem, but it's actually in two separate stories. A script can only select contiguous text from the same story (a single set of threaded text frames), just as you cannot select all text in two non-connected text frames.