3 Replies Latest reply on Apr 6, 2008 8:02 AM by [Jongware]

    Repeating my Question - Please answer asap

      Hi there, I posted this query last week but got reply to give the details why I have to use this script. I gave the details but got no replies after that. So here I go with the details repeating my question. Please read and help asap.
      It's CS2. I need to put some text in all (many) documents I work regularly. Instead of copying from the previous file or any other source, as the text is same for all, I thought of writing the script with the text itself. Running that will create text frame and write the text.
      I was almost there but was unable to bold the title of the text which I mentioned earlier as a first paragraph with two words.

      Also I couldn't give the my color swatch to the text.

      Here is my script:

      var myTextFrame = app.activeWindow.activePage.textFrames.add()
      var myParagraph = myTextFrame.paragraphs.item(0)
      var myFont = app.fonts.item("Arial")
      myTextFrame.geometricBounds = ["11.2in", "6in","9.57in","0.5in"];
      myTextFrame.contents = "First Paragraph"
      myTextFrame.parentStory.insertionPoints.item(-1).contents = "\r This is Second paragraph.";
      myTextFrame.parentStory.insertionPoints.item(-2).contents = "\r\rHere comes the Third Paragraph with extra para space";
      myParagraph.parentStory.appliedFont = myFont
      myParagraph.parentStory.pointSize = 8
      myParagraph.paragraphs.item(-1).spaceAfter = "0.05in"

      Waiting for valuable solution. Two questions 1) making bold first two words 2) font color with my cutomized swatch

      Many thanks in advance.
        • 1. Re: Repeating my Question - Please answer asap
          Martin Fischer Level 2
          Hi Prasant,

          to apply fontstyle 'Bold' to the first two words of a paragraph use itemByRange:

          myParagraph.words.itemByRange( 0,1 ).fontStyle = 'Bold';

          To apply a customized swatch set the fillColor-property of the text:

          myParagraph.fillColor = app.activeDocument.swatches.item( 'customizedSwatch' );

          Martin Fischer
          • 2. Re: Repeating my Question - Please answer asap
            Level 1
            Hi Martin

            THANKS A LOT. The first one worked. I just have to change that code as per my requirement and it JUST WORKED. AMAZING

            Second one is still not working and need to do some more research on that.
            myParagraph.fillColor = app.activeDocument.swatches.item( 'customizedSwatch' );

            Any other suggestions please?

            Thanks a lot.
            • 3. Re: Repeating my Question - Please answer asap
              [Jongware] Most Valuable Participant
              The line is correct. What is your error message?

              By way of research, copied from the Help:
              Property: fillColor
              Type: Swatch
              Access: r/w
              Description: The swatch (color, gradient, tint, or mixed ink) applied to the fill of the Paragraph. . Can also accept: String.

              Are you aware that 'customizedSwatch' should be replaced with the name of your color swatch? Or create a new swatch and call it 'customizedSwatch'.