0 Replies Latest reply on Jun 2, 2015 3:13 PM by MadMac55

    Closing Libraries upon Exit / Quit

    MadMac55 Level 1

      My simple finding is that palettes that are expanded will close; palettes that are collapsed will not.  Is there a better language call that 1) first expands the palette, then closes the libraries?  or 2) just flat-out closes the libraries?  :-)

       

       

      In this sample, collapsed palettes stay open, expanded will close.

       

      function CloseLibraries(myEvent) {

          var myLibraries = app.libraries; // all open libraries

          if(myLibraries.length > 0) {

              var libraryNames = (myLibraries.everyItem(0).name).toString(); // string containing all names

                  for (var i = myLibraries.length - 1; i > -1; i--) { // looping backwards because closing libraries changes the indexes

                      if (myLibraries[i].associatedPanel != null && myLibraries[i].associatedPanel.visible == true) {

                          myLibraries[i].associatedPanel.visible = false;

                      }

                      myLibraries[i].close(); // file closed

                  }