2 Replies Latest reply on Mar 12, 2017 4:59 AM by Ananth@desgin

    the answer to the options under each question that matches the character style.

    uniqued_tol Level 1

      I have a long document. I want to find the answer to the options under each question that matches the character style. Do you have any idea? Thanks in advance.

       

      1.jpg2.jpg

        • 2. Re: the answer to the options under each question that matches the character style.
          Ananth@desgin Level 3

          Try this code.

          #target indesign
          var myDoc =app.activeDocument;
          var myarray =[];
          var myarray_1 = [];
          var my_Final = [];
          app.findGrepPreferences = app.changeGrepPreferences = null;
          app.findGrepPreferences.findWhat = "^\\d";
          myFound = myDoc.findGrep();
          for(var i=0; i<myFound.length; i++)
          {
              if(myFound[i].contents)
              {
              myarray.push(myFound[i].contents);
              var myjoin = myarray.join("")
             }
            }
          app.findGrepPreferences = null;
          app.findGrepPreferences.appliedCharacterStyle = "Blue";
          myFound_1 = myDoc.findGrep();
          for(var i=0; i<myFound_1.length; i++)
          {
              if(myFound_1[i].contents)
              {
              myarray_1.push(myFound_1[i].contents);
              var myjoin_1 = myarray_1.join("")
            }
             }
          for(a=0; a<myjoin.length&&myjoin_1.length; a++)
          {
           var my_Final$ =myjoin[a]+myjoin_1[a]; 
           my_Final.push(my_Final$)
          var final_join = my_Final.join("\n")
          }
          
          var myFile_path = app.activeDocument.filePath;
          var myReport_name = myDoc.name.replace(".indd", ".csv");
          var myFinalpath = myFile_path+ "/"+myReport_name;
          var myTextFile = new File(myFile_path+"/"+myReport_name)
           myTextFile.open("w");
           myTextFile.write(final_join)
           myTextFile.close();