2 Replies Latest reply on Jun 26, 2013 10:22 PM by Laubender

    Capturing formatted text

    Paul Chernoff Level 1

      I am some code that cuts up the text in a text box and puts it in mulitple text boxes. The problem is that it gets formatted text but I need to capture the formatted text. My code that gets the text is below:


      set myText to contents of selection of myDocument


      But this only captures the plain text. How should I change my approach?

        • 1. Re: Capturing formatted text
          RobertKyle Level 2

          Two ideas:


          1) Select and cut the overset text from the original text box. Create or find the second box and paste. Cut the overset again. Repeat until there is no more overset. The clipboard gets styled text.


          2) Create the second frame and thread it to the first. Repeat. Be aware that type will reflow from one threaded frame to another when/if changes are made. This might be a good thing or a bad thing.


          I have an old (ID 2.0) AppleScript and a newer Javascript (CS5.5) for #2. Be glad to share.

          • 2. Re: Capturing formatted text
            Laubender Adobe Community Professional & MVP

            @Paul – I'm not too much into AppleScript, but you are using the "contents" (unformatted text) property of an object.
            How would it work if you are using the text directly?


            Dummycode here (don't know if it will work at all):


            set myText to text of selection of myDocument


            in JavaScript (ExtendScript) that would be:


            var myText = app.selection[0].texts[0];


            What exactly is selected? A text frame? Or is it the text itself?