1 Reply Latest reply on Jun 22, 2011 5:48 AM by jamesspurck

    Moving content from one page to another - worked in CS3 but not CS5.5

    jamesspurck

      We were using the following script portion in InDesign CS3 but we are now using CS5.5 and this portion of our script does not work. Does anyone know why?

       

      This script creates a dialog window that will have configs autamatically set. Once executed, it goes to a specfic page and selects all items on that page and moves the content to another page. In this case it is taking all the contents "grouped together" of Page 2 and moving them to page 1. It does not work in CS5.5. Thanks ahead of time!

       

      <<script begins==================

       

      //GO TO PAGE 2---------------------------------------------------------------------------------------- -----------
      var myDocument = app.activeDocument;
      with (myDocument){
      var mymovepage = pages.item(1)
      app.activeWindow.activePage = mymovepage
      }
      //
      //SELECT ALL ITEMS ON PAGE 2--------------------------------------------------------------------------
      app.select(app.activeWindow.activePage.allPageItems);
      //
      //MOVE CONTENTS FROM PAGE 2----------------------------------------------------------------------
      try {
      var myDocument = app.activeDocument;
      with (myDocument){
      var myselection = selection;
      var myprefs = documentPreferences.properties;
      var mymaxpagenumber = myprefs.pagesPerDocument;
      var theselectcount = selection.length;
      //make the dialog
      var myDialog = app.dialogs.add({name:"Move the Selected Items", canCancel:true});
      with (myDialog){
      with (dialogColumns.add()){
      with (borderPanels.add()){
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Which page would you like the"});
      staticTexts.add({staticLabel:"selected item(s) to move to?"});
      }
      with (dialogColumns.add()){
      staticTexts.add({staticLabel:"Page 1"});
      var mypageinfo = integerEditboxes.add({minWidth:40, minValue:1, maximumValue:mymaxpagenumber});
      }
      }
      if (theselectcount > 1){
      with (borderPanels.add()){
      staticTexts.add({staticLabel:"Group Items", minWidth:102});
      var myradiogroup = radiobuttonGroups.add();
      with (myradiogroup){
      var myyesradiobutton = radiobuttonControls.add({staticLabel:"Make into a Group", checkedState:false});
      var mynoradiobutton = radiobuttonControls.add({staticLabel:"Leave as Selected"});
      }
      }
      }
      }
      }
      if (myDialog.show() == true){
      if (theselectcount>1){
      var mygroupungroup = myradiogroup.selectedButton;
      }
      var mypage = mypageinfo.editContents;
      myDialog.destroy();
      }
      var myoldviewprefs = viewPreferences.properties
      var myprefs = documentPreferences
      with (myprefs){
      var mymaxpagenumber = pagesPerDocument
      }
      if (viewPreferences.rulerOrigin = RulerOrigin.spreadOrigin){
      var myoldorigin = RulerOrigin.spreadOrigin;
      viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
      }
      var currentPage = myDocument.layoutWindows.item(0).activePage
      var myselection = selection;
      var mycount = myselection.length
      if (theselectcount > 1){
      myStuff = new Array();
      for (i=0; mycount>i; i++){
      myStuff.push(myselection[i]);
      }
      mygroup = app.activeWindow.activePage.groups.add(myStuff);
      var mymovepage = pages.item(mypage - 1)
      var myBounds = mygroup.geometricBounds
      var a = myBounds[0]
      var b = myBounds[1]
      var c = myBounds[2]
      var d = myBounds[3]
      mygroup.move(mymovepage, undefined)
      mygroup.move([b, a], undefined)
      if (mygroupungroup == 1)
      mygroup.ungroup()
      }
      else{
      var mymovepage = pages.item(mypage - 1)
      var mysingleselection = selection[1]
      var myBounds = mysingleselection.geometricBounds
      var a = myBounds[0]
      var b = myBounds[1]
      var c = myBounds[2]
      var d = myBounds[3]
      mysingleselection.move(mymovepage, undefined)
      mysingleselection.move([b, a], undefined)
      }
      app.activeWindow.activePage = mymovepage
      if (myoldorigin = RulerOrigin.spreadOrigin){
      viewPreferences.rulerOrigin = RulerOrigin.spreadOrigin
      }
      }
      }
      catch (e) {
      if (app.documents.length == 0){
      alert ("No InDesign documents are open. Open a document, select item(s) you would like to move.");
      }
      else {
      if (app.selection.length == 0){
      alert ("Nothing is selected. Please select item(s) you would like to move.");
      }
      }
      }
      //
      //
      ==================Script ends>>