1 Reply Latest reply on Jun 25, 2013 2:14 AM by virender_CTS

    Hello All, I have document that has 10 text boxes and each box starts with parastyle H1.

    virender_CTS Level 1

      Hello All, I have document that has 10 text boxes (each on different page) and each box starts with parastyle H1 and then text and headings. The text boxes are independent.

      I want to export the text as RTF for all textboxes whose text starts with H1 parastyle as separate files.

       

      macos 10.8, CS6, extend script

       

      Regards

      Virender

       

      PS: there are other pages having tables, figure but dont have text boxes.

        • 1. Re: Hello All, I have document that has 10 text boxes and each box starts with parastyle H1.
          virender_CTS Level 1

          Dear all, I am able to wrote script but sometimes it showed error at 5th line due to yet unknown reason. Is there any exception handling process in extend script?

           

          var mydoc = app.activeDocument;

           

          var myfolder =  "~/Desktop/virender_mac_L/apple_script/testing";

          for (var s=0; s< mydoc.stories.length; s++)

          {

               var st = mydoc.stories[s];    //     var st = mydoc.stories[s].paragraphs[0];

           

               if (st.paragraphs[0].appliedParagraphStyle.name == "H1")  // here i use to get error once i few stories get exported but when i clicked on Run (two or three times) then remaining stories got also exported and alert("Done") got executed.

               {

                 var fileName = s + st.paragraphs[0].contents + ".rtf";

                 myPath = myfolder + "/" + fileName;

                 myFile = new File (myPath);

                 st.exportFile(ExportFormat.rtf, myFile);

              }

          }

          alert("Done");