3 Replies Latest reply on May 9, 2016 11:21 PM by karthiks94217840

    Select, Cut, Paste Table Script

    micheller81371267

      Hello, any body who can help create a script that can select a table from a text frame, cut and paste on a paste board. I worked with XML that flows to my InDesign template. The tables comes in with the text frame. A cut and paste process consumes my time especially having 100+ tables in the document.

       

      Thank you!

      Michelle

        • 1. Re: Select, Cut, Paste Table Script
          tpk1982 Level 4

          this will useful to cut all tables and paste in the same page (not pasteboard)

           

          var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();  
          for(var i=0; i<myTable.length; i++)  
          {  
              myTable[i].select()  
              app.cut()
              app.paste() 
          }
          

           

           

          Thanks,

          Karthi

          • 2. Re: Select, Cut, Paste Table Script
            karthiks94217840 Level 2

            Hi

             

            XML work flow? try this

             

            *********************

            var myDocument = app.activeDocument; 

            var root = myDocument.xmlElements[0]; 

            var myXMLidElement = root.evaluateXPathExpression("//footnote");  //("//table");

            alert(myXMLidElement.length);

            for (var i = 0; i < myXMLidElement.length; i++) 

            {   

              myDocument.select(myXMLidElement[i]); 

              var myTextframe = myXMLidElement[i].placeIntoInlineFrame(["26.5p","5p"]);

              myTextframe.fit(FitOptions.FRAME_TO_CONTENT);

            myTextframe.anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;

            myTextframe.anchoredObjectSettings.anchorPoint = AnchorPoint.BOTTOM_LEFT_ANCHOR;

            myTextframe.anchoredObjectSettings.horizontalAlignment = HorizontalAlignment.LEFT_ALIGN;

            myTextframe.anchoredObjectSettings.horizontalReferencePoint = AnchoredRelativeTo.TEXT_FRAME;

            myTextframe.anchoredObjectSettings.anchorXoffset = "30p";

            //~ myTextframe.anchoredObjectSettings.anchorYoffset = "36p";

            myTextframe.textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP; 

            myTextframe.textWrapPreferences.textWrapOffset = new Array (".5p", 0, ".5p", 0)

            }

            alert("Done")

             

            *********************

             

            Thanks

            • 3. Re: Select, Cut, Paste Table Script
              karthiks94217840 Level 2

              Hi

               

              Don't use above coding.

               

              Try this one

               

               

              var myDocument = app.activeDocument;

              var root = myDocument.xmlElements[0];

              var myXMLidElement = root.evaluateXPathExpression("//table");

              alert(myXMLidElement.length);

              for (var i = 0; i < myXMLidElement.length; i++)

              {  

                myDocument.select(myXMLidElement[i]);

                var myTextframe = myXMLidElement[i].placeIntoInlineFrame(["26.5p","5p"]);

                myTextframe.fit(FitOptions.FRAME_TO_CONTENT);

              myTextframe.anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;

              myTextframe.anchoredObjectSettings.anchorPoint = AnchorPoint.BOTTOM_LEFT_ANCHOR;

              myTextframe.anchoredObjectSettings.horizontalAlignment = HorizontalAlignment.LEFT_ALIGN;

              myTextframe.anchoredObjectSettings.horizontalReferencePoint = AnchoredRelativeTo.TEXT_FRAME;

              myTextframe.anchoredObjectSettings.anchorXoffset = "30p";

              //~ myTextframe.anchoredObjectSettings.anchorYoffset = "36p";

              myTextframe.textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;

              myTextframe.textWrapPreferences.textWrapOffset = new Array (".5p", 0, ".5p", 0)

              }

              alert("Done")

               

              Thanks

              1 person found this helpful