5 Replies Latest reply on Feb 17, 2012 3:17 AM by snegig

    Replace paragraph style [JS]

    snegig Level 1

      Hi All,

       

      (1)

      I have a JS code for replace paragraph style (come word file (floppy style)) its working good. But my problem is that when run this code if find paragraph style not define (word file (floppy style)) in flow indesign file then error. Is that possible if paragraph style not find then ignore then run next step. Please see code below

       

      var myDocument = app.activeDocument;

      var myParagraphStyleA = myDocument.paragraphStyles.item("h1");

      myParagraphStyleA.remove(myDocument.paragraphStyles.item("1H: One Head"));

       

       

      (2)

       

      You have any script for delete only unused  (para/char (Floppy style)) only.

       

      Screen shot 2012-02-16 at 4.38.32 PM.png

       

      Thank you so much adv.

       

      regard

      snegig

        • 1. Re: Replace paragraph style [JS]
          [Jongware] Most Valuable Participant

          (1) If you run this line on a document without a "h1" style:

           

          var myParagraphStyleA = myDocument.paragraphStyles.item("h1");

           

          then what is the value in myParagraphStyleA?

           

          (2) What property in a paragraph style makes the floppy disk icon appear?

          • 2. Re: Replace paragraph style [JS]
            Harbs. Level 6

            [Jongware] wrote:

             

            (2) What property in a paragraph style makes the floppy disk icon appear?

            myStyle.imported

            • 3. Re: Replace paragraph style [JS]
              [Jongware] Most Valuable Participant

              Well I was hoping snegig would find that ... You also must know the answer to (1).

              • 4. Re: Replace paragraph style [JS]
                Harbs. Level 6

                Yeah. But that takes more than a few words...

                 

                Harbs

                • 5. Re: Replace paragraph style [JS]
                  snegig Level 1

                  Hello Sir (Harbs, Jongware and other),

                   

                  I am really sorry for late answering. I am junior so heavy workload.

                   

                  This line code "h1" paragraph style actually comes ms-word file (floppy style).

                  var myParagraphStyleA = myDocument.paragraphStyles.item("h1");

                   

                  Second line code "1H: One Head" is InDesign CS4 paragraph style.

                  var myParagraphStyleA = myDocument.paragraphStyles.item("h1");

                   

                  If "h1" PS comes (ms-word) in InDesign then code run good. In case if "h1" PS not comes in InDesign file then script error.

                  I have just mapping both Paragraph Style (PS) (ms-word, InDesign) if both styles mapping then script run. When run same script other chapters if any tag not come form (ms-word) but whose PS define in script then script error.

                   

                  My question is that if any PS comes from (ms-word) if this style not define in script, script run properly otherwise script display massage these PS (ms-word(floppy)) not define in your script code.

                   

                   

                  (2) My second query

                  If all PS mapping by script but ms-word style (floppy) appear in my indesign file. Is that possible these PS replace (mapping) ms-word style (floppy) automatically remove.

                   

                  Thank you so much

                  Regard

                  snegig