0 Replies Latest reply on May 13, 2014 7:48 AM by NeoMental

    Open up "Save As" dialog in javascript

    NeoMental

      Hello all,

       

           I am a newbie to scripting and to be honest it makes my head hurt lol, Kudos to all that make this look easy. I found some good resources but following everything is going to take a bit. I have am using the object model viewer and its a great resource. Long story even longer I am trying to automate a bunch of repetitive tasks that we have to run on a ton of pre-built documents. I have been hobbling together some code that has been working. everything is working and I can worry about cleaning up the code later (for my sake. I have OCD)

       

      I can't seem to find a way to open up the "save as" dialog so that the user can save the document to a directory that will change from week to week. The file name will vary across the run of files. I don't need anything to automate that part. I just want it to pop up and then continue the run. I'd like to do this at the start of the script so that when all the changes are made I can just have the document close. (I haven't included the closing code yet) Is this possible? I cant seem to find anything out there to point me in the right direction.

       

      Here is what I have so far.

       

      myDoc=app.activeDocument; 

      for (var  n=myDoc.masterSpreads.length-1; n>=0; n--){ 

           if (isMasterSpreadInUse(myDoc.masterSpreads[n])==false){ 

                myDoc.masterSpreads[n].remove(); 

           } 

      function isMasterSpreadInUse(myMasterSpread){ 

           var myDoc=myMasterSpread.parent; 

           for (var  n=myDoc.masterSpreads.length-1; n>=0; n--){ 

                if (myDoc.masterSpreads[n].appliedMaster==myMasterSpread){ 

                     return true; 

                } 

           } 

           for (var  n=myDoc.pages.length-1; n>=0; n--){ 

                if (myDoc.pages[n].appliedMaster==myMasterSpread){ 

                     return true; 

                } 

           } 

           return false; 

       

       

      Array.prototype.filter = function(collection) { 

                var k, i, con, ids = collection.everyItem().id; 

                con: for (k = ids.length - 1; k >=0; k--)  

                          for (i = 0; i < this.length; i++) 

                          if (this[i].id == ids[k]) { 

                               ids.splice(k, 1);  

                               continue con; 

          

           } 

                return ids;     // array with unmatched ids from collection 

                } 

       

      var  

                mL = app.activeDocument.pageItems.everyItem().itemLayer, 

                mUnusedLayersID = mL.filter(app.activeDocument.layers), 

                len = mUnusedLayersID.length; 

       

      while (len-->0) 

                app.activeDocument.layers.itemByID(mUnusedLayersID[len]).remove();

       

       

      var layers = app.activeDocument.layers.everyItem().getElements();

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

      if (layers[i].name[0] == "X"){

           layers[i].remove();

      }

      }

       

       

      app.documents.everyItem().xmlElements.item(0).xmlElements.everyItem().untag();

       

       

      myPreset = app.printerPresets.item("AdQ 8½x11");

       

       

      app.activeDocument.print(false, myPreset);

       

       

      SaveOptions.YES