2 Replies Latest reply on Jun 28, 2016 2:58 PM by jeremy0013

    Duplicate and Open File Fail

    jeremy0013

      Having an issue with this script.  It works fine when running it with the file open.  But when adding an open file command, Illustrator give me an MRAP error?? Am I doing something wrong?

       

      // Global

          var idoc = activeDocument;

          var saveOutDirectory = (File ("MyDirectory"));

         

      // Save Out

      function saveFile() {

          for (var i = 0; i < idoc.dataSets.length; i++) {

              currentDataset = idoc.dataSets[i];

              currentDataset.display(); 

              idoc.saveAs(File (saveOutDirectory + "/" +  currentDataset.name +  "_MyFile.pdf"), myOpts);

          }

      };

       

       

      // Remove - Print Graphics and Artboards

      function removePrintAB() {

          var artbs = idoc.artboards;

          for (var i = artbs.length-1 ; i >= 0; i--) {

              if (artbs[i].name != "MySpecialArtboard") {

                  artbs.setActiveArtboardIndex(i);

                  idoc.selectObjectsOnActiveArtboard();

                  app.cut();

                  artbs[i].remove();

          }}

      };

       

      // Duplicate Original File

      var TempFile = (File (saveOutDirectory + "/" + idoc.name));

      TempFile.copy (saveOutDirectory + "/" + "temp file.pdf" );

       

      open(File (saveOutDirectory + "/" + "pellon_temp.pdf"));

       

      removePrintAB();

      saveFile();