5 Replies Latest reply on May 24, 2012 7:50 AM by nikasd8

    making the first line in each paragraph bold


      hello all

      I have been reading this forum but i cant really seem to find the answer i need.

      Here is my problem, we are planning to automate the flowing of text in our organisation, this is what i have to do

      -read story entries from a database

      -flow the text in to a text box of particular width eg 4.5cm

      -each paragraph will be sepearted by 2 new lines

      - select the first line of each paragraph then make it bold.


      from the above list i can do everything except the select first line of paragraph and make it bold. I have been looking for text selection as far as i can see there is a function called textframe.select?

      Can anybody help me out with this please?

        • 2. Re: making the first line in each paragraph bold
          nikasd8 Level 1

          ty for the feedback, i looked in to this option may i know which versions of indesign does this work on? We are using indesign cs2.

          • 3. Re: making the first line in each paragraph bold
            Harbs. Level 6

            They were introduced in CS4.



            • 4. Re: making the first line in each paragraph bold
              [Jongware] Most Valuable Participant

              That severly limits your options. (Which reminds me, you might want to state a major detail like that up front next time.)


              The straightforward solution would be to apply your bold font (or, better: a character style) to the first line of each paragraph using the .lines property of a paragraph. Uh -- customary link to the HTML version of the OMV omitted, it seems I don't go back as far as CS2 ... (There is a CHM for it at http://www.jongware.com/idjshelp.html).


              This ought to work:


              app.selection[0].paragraphs[0].lines[0].appliedCharacterStyle = "YourBoldCharStyle";


              ... where your cursor is inside the paragraph you want to change. Adjust at will to cater for your special needs.


              There is a downside to the straightforward method, though. Unless you are using a special font which has bolds with the same width as its regular (quite unusual), the text will reflow after you applied it. So then there are one or more bold words on the next line, and you should remove the bold char style from those. But! At that point InDesign may decide those non-bold words can fit again on the first line!


              Well-written code does not help, as it might be possible the same word oscillates back and forth with every change between the first and the second line, each time getting it wrong ... So at *some* point you are going to have to help poor ID a bit; perhaps by fixating that first line with No Break applied to it.

              • 5. Re: making the first line in each paragraph bold
                nikasd8 Level 1

                thank you very much for your help. I did figure out how to do it finally after a lot of "fiddle"-programming . The link you also pasted was  very usefull cause the reference CHM was a boon.

                well my basic algorithm was (vbscript)

                place some text

                app.paragraphs(1).lines(1).appliedFont = "somefontname Bold"


                And the second thing about the words being wrapped to second line, well i guess i guess the easiest would be to make the second line non bold after the first one is made bold, hacky i know but "just works"!


                thank you very much Jongware, harbs