1 Reply Latest reply: Feb 21, 2012 1:08 PM by absqua RSS

    Formatting text from the beginning

    kiwibell

      Hello wise ones,

       

      I am just begining to learn about applescript but have no teacher besides Google (which is great but it's hard to know where to start!).

       

      How do I specify where I want the scripting to begin?

       

      I'm working in Indd cs5.5 and wish to start with the first line of the first paragraph in the first text frame on the first page of the active document.

       

      Also, I need to apply a style (that I have already set up in Indd) to this first line. Any ideas?

       

      Any help, much appreciated!

       

      Bella *

        • 1. Re: Formatting text from the beginning
          absqua Community Member

          Is there a reason you're going with Applescript? If you have no scripting experience and your primary goal is to script the Adobe Creative Suite products, I would recommend you start in with JavaScript instead. There are a lot more resources for learning it—start here—and you'll get a lot more help on this board.

           

          In JavaScript, you would do something like:

           

          app.activeDocument.pages[0].textFrames[0].paragraphs[0].appliedParagraphStyle = app.activeDocument.paragraphStyles.item("style name");
          

           

          Note that there is no point in applying a paragraph style to a line; applying it to the first line will apply it to the whole first paragraph. Also: you'll have to define what you mean by the "first text frame"; the first textFrame in the page's textFrames collection—what we get  from pages[0].textFrames[0]—is actually the last frame that was created. If you want, say, the top-leftmost frame, you have to go through a bit more. And, this will only work if the paragraph style you're trying to apply isn't in a group.

           

          The Applescript would be something like:

           

          tell application "Adobe InDesign CS5.5"

              set the applied paragraph style of the first paragraph of the first text frame of the first page of the active document to paragraph style "style name" of the active document

          end tell

           

          But I don't really know Applescript. Hope this helps.

           

          Jeff