3 Replies Latest reply on Nov 8, 2010 2:41 AM by tansk02

    Delete unused master spread

    tansk02 Level 1

      Hi all,

       

      Is anybody know how to delete unused master spread in document.

       

      Thanks in advance.

      tanshk

        • 1. Re: Delete unused master spread
          tansk02 Level 1

          Need JS code. Please provide.

          • 2. Re: Delete unused master spread
            Haakenlid Level 3

            This will work in CS3 at least. It's not very fast, though. It will remove all unused master spreads.

             

            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;
            }
            
            • 3. Re: Delete unused master spread
              tansk02 Level 1

              Thanks for your positive answer.