0 Replies Latest reply on Oct 29, 2010 1:12 AM by mmiikkeemike

    remove frame problem?

    mmiikkeemike

      This script can't works in second file (if file name is 01xxx, 02xxx, 03xxx, if 01xxx infront of the windows, 03xxx can't work, if 02xxx infront of the windows 03xxx can't work) why?? please help

       

       

      Function here

      __________________________________

       

      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;


      var myDialog = app.dialogs.add({name:"Hide / Show / Deleted JOB BAR? ",canCancel:true});
      with(myDialog){
      with(dialogColumns.add()){
        with(borderPanels.add()){
        staticTexts.add({staticLabel:"JOB BAR (Please Choose)"});
        var myRadioButtonGroup = radiobuttonGroups.add();
        with(myRadioButtonGroup){
        var myHide = radiobuttonControls.add({staticLabel:"Hide"})
       
        var myShow = radiobuttonControls.add({staticLabel:"Show"})
       
        var myDeleted = radiobuttonControls.add({staticLabel:"Deleted"})
        }
      }
      }
      }

      for(a = 0; a < app.documents.length; a++){
         
      if (app.documents.item(a).colors.item ("JOB BAR") == null)
      app.documents.item(a).colors.add ({name:"JOB BAR", model:ColorModel.spot, colorValue:[100,100,0,0]});
      var myColor = app.documents.item(a).colors.item ("JOB BAR")

      var myRemoveColor = app.documents.item(a).colors.item("Job Bar");
      var replaceColor = app.documents.item(a).colors.item("JOB BAR");

      try{
      myRemoveColor.remove(replaceColor);
      }
      catch(myRemoveColor){};   
         
      try{
      var myLayer = app.documents.item(a).layers.item("JOB BAR LAYER");
      myLayer.visible=true;
      }
      catch(myLayer){
      var myLayer = app.documents.item(a).layers.add({name: "JOB BAR LAYER", visible: true});
      myLayer.label = "JOB BAR LAYER";
      app.documents.itemByRange(0,-1).layers.item("JOB BAR LAYER").locked=false;
      }
      }


      var myResult = myDialog.show();
      if(myResult == true){
      for(d = 0; d < app.documents.length; d++){
      if(((myDeleted.checkedState == true)&&myHide.checkedState == false)&&(myShow.checkedState == false)){
      var myActiveDoc = app.documents.item(d);
      app.activeDocument = myActiveDoc;
      app.findTextPreferences = NothingEnum.nothing;
      app.changeTextPreferences = NothingEnum.nothing;
      app.findTextPreferences.fillColor = myColor;
      app.findTextPreferences.findWhat = "♠ INTERNAL REF.";
      app.findChangeTextOptions.includeLockedLayersForFind = true;
      app.findChangeTextOptions.includeLockedStoriesForFind = true;
      app.findChangeTextOptions.wholeWord = true;
      app.findChangeTextOptions.includeMasterPages = true;
      var myFoundItems = app.documents.item(0).findText();
      app.findTextPreferences = NothingEnum.nothing;
      app.changeTextPreferences = NothingEnum.nothing;
      for (j = 0; j < myFoundItems.length; j++) {
      var myFrame = myFoundItems[j].parentTextFrames;
      for (p = 0; p < myFrame.length; p++) {
      var mySelectedFrames = app.select(myFrame[p]);
      var mySelection = app.selection[p];
      mySelection.itemLayer.locked=false;
      myFrame[p].locked=false;
      myFrame[p].remove();}
      try{
      app.documents.itemByRange(0,-1).layers.item("JOB BAR LAYER").remove();
      }
      catch(e){
      }
      }
      }

      else if((myHide.checkedState == true)&&(myShow.checkedState == false)&&(myDeleted.checkedState == false)){
      var myActiveDoc = app.documents.item(d);
      app.activeDocument = myActiveDoc;
      app.findTextPreferences = NothingEnum.nothing;
      app.changeTextPreferences = NothingEnum.nothing;
      app.findTextPreferences.fillColor = myColor;
      app.findTextPreferences.findWhat = "♠ INTERNAL REF.";
      app.findChangeTextOptions.includeLockedLayersForFind = true;
      app.findChangeTextOptions.includeLockedStoriesForFind = true;
      app.findChangeTextOptions.wholeWord = true;
      app.findChangeTextOptions.includeMasterPages = true;
      var myFoundItems = app.documents.item(0).findText();
      app.findTextPreferences = NothingEnum.nothing;
      app.changeTextPreferences = NothingEnum.nothing;
      for (j = myFoundItems.length - 1; j >= 0; j--) {
      var myFrame = myFoundItems[j].parentTextFrames;
      for (p = myFrame.length - 1; p >= 0; p--) {
      var mySelectedFrames = app.select(myFrame[p]);
      var mySelection = app.selection[p];
      mySelection.itemLayer.locked=false;
      myFrame[p].locked=false;
      mySelection.itemLayer = "JOB BAR LAYER";}}
      app.documents.itemByRange(0,-1).layers.item("JOB BAR LAYER").visible=false;
        app.documents.itemByRange(0,-1).layers.item("JOB BAR LAYER").locked=true;
                  app.activeDocument.activeLayer = app.activeDocument.layers.item ("Layer 1");}

      else if((myHide.checkedState == false)&&(myShow.checkedState == true)&&(myDeleted.checkedState == false)){
      var myActiveDoc = app.documents.item(d);
      app.activeDocument = myActiveDoc;
      app.findTextPreferences = NothingEnum.nothing;
      app.changeTextPreferences = NothingEnum.nothing;
      app.findTextPreferences.fillColor = myColor;
      app.findTextPreferences.findWhat = "♠ INTERNAL REF.";
      app.findChangeTextOptions.includeLockedLayersForFind = true;
      app.findChangeTextOptions.includeLockedStoriesForFind = true;
      app.findChangeTextOptions.wholeWord = true;
      app.findChangeTextOptions.includeMasterPages = true;
      var myFoundItems = app.documents.item(0).findText();
      app.findTextPreferences = NothingEnum.nothing;
      app.changeTextPreferences = NothingEnum.nothing;
      for (j = myFoundItems.length - 1; j >= 0; j--) {
      var myFrame = myFoundItems[j].parentTextFrames;
      for (p = myFrame.length - 1; p >= 0; p--) {
      var mySelectedFrames = app.select(myFrame[p]);
      var mySelection = app.selection[p];
      mySelection.itemLayer.locked=false;
      myFrame[p].locked=false;
      mySelection.itemLayer = "JOB BAR LAYER";}}
      app.documents.itemByRange(0,-1).layers.item("JOB BAR LAYER").visible=true;
        app.documents.itemByRange(0,-1).layers.item("JOB BAR LAYER").locked=false;}
                

      else{
      exit;
      }
      }
      }

       

      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

       

      ________________________________________