2 Replies Latest reply on Aug 25, 2011 5:45 AM by Ken Krugh

    Cutting and Pasting Formatted Text

    Ken Krugh Level 1

      I have a script that searches for text with an outline color, removes the outlnie color, cuts it from the main "body" text, adds an anchored frame, applied an object style to that frame and pastes the cut text in the frame.

       

      Everything works great except that it is REALLLLLLYYYY SSSSSLLLLLOOOOOWWWWW.....

       

      I'm wondering two things. 1, is there a way to cut text without havnig to select it first (which seems to be a slow point) and keep any current formatting, and 2, is there a way to get InDesign to stop jumping to the page on which the cutting is occurring? It looks like InD scrolls the pages when the cut occurs.

       

      My code looks roughly like this (VBA, InD CS3).

       

      I define the text area so search

                Set SChar = InD.Selection(1).ParentStory.Characters(InD.Selection(1).InsertionPoints(-1).Index)
                Set EChar = InD.Selection(1).ParentStory.Characters(-1)
                Set SrchTxt = InD.Selection(1).ParentStory.Texts.ItemByRange(SChar, EChar)

      Set up my search stuff here...

      Then execute the search as such:

                Set Foundd = SrchTxt(1).FindText

       

      I thought about using something like Foundd(i).cut or trying to simply set the text of the new frame to the text of the old frame but didn't see a way to do that and keep any potential formatting.

        • 1. Re: Cutting and Pasting Formatted Text
          Laubender Adobe Community Professional & MVP

          Ken,

          I'm not into VB scripting, but in ExtendScript (JavaScript) instead of using cut & paste I will move the text to insertion point [0] of your anchored text frame.

          No selection needed for that.

           

          Uwe

          1 person found this helpful
          • 2. Re: Cutting and Pasting Formatted Text
            Ken Krugh Level 1

            WOW! Between not having to select the item and InD no longer scrolling through the pages I'm getting at least double the speed! Never thought of the move function in relation to text.

             

            Thanks much!

             

            Now maybe the only other thing that might get a little more speed is adding the frame at the initial size I need rather than adding it then resizing it. Any thoughts on that would also be greatly appreciated.

             

            Thanks again!

            Ken