6 Replies Latest reply on Jul 26, 2015 2:47 AM by Peter Kahrel

    move table within a textframe?

    aviR Level 1

      Hii

      Can anyone please tell me how can I move a table within a textframe?

      Is it possible to do so using vb.net?

      Please please help

       

      Thanks

        • 1. Re: move table within a textframe?
          Jump_Over Level 5

          Hi,

           

          It supposes to go similar like moving text.

          How to find text which handles a table? Take character covered by insertionPoints before and after table.

          Example:

          // that is javascript so for vbs use the logic rather
          // assumed that cursor is placed within table's parentStory and it is a new destination.
          // it takes 1st table found in the story
          
          var
            mStory = app.selection[0].parentStory,
            start = mStory.tables[0].storyOffset,
            tableHandler = mStory.insertionPoints.itemByRange(start, mStory.insertionPoints.nextItem(start)).characters[0],
            target = app.selection[0].insertionPoints[0],
            targetBase = mStory.insertionPoints.itemByRange(target, mStory.insertionPoints.nextItem(target)).characters[0];
          
            tableHandler.move(LocationOptions.BEFORE, targetBase);
          
          

           

          Jarek

          • 2. Re: move table within a textframe?
            aviR Level 1

            Hi

            Thanks for replying.

            I will try your code through vb and let me how it works out?

            Thanks

            • 3. Re: move table within a textframe?
              Peter Kahrel Adobe Community Professional & MVP

              That's uncharacteristically verbose, Jarek -- can be done with these three lines:

               

              var story = app.selection[0].parentStory;
              var table = story.characters[story.tables[0].storyOffset.index];
              table.move (LocationOptions.BEFORE, app.selection[0]);
              

               

              And for the heck of it, sacrificing readability for brevity, in one line:

               

              app.selection[0].parentStory.characters[app.selection[0].parentStory.tables[0].storyOffset.index].move(LocationOptions.BEFORE, app.selection[0]);
              

               

              Peter

              • 4. Re: move table within a textframe?
                Jump_Over Level 5

                Thanks for this remark, Peter.

                 

                Can't remember when I persueded myself that move parameter suppose to be the same kind of object (IP to IP; char to char and so on)

                 

                Jarek

                • 5. Re: move table within a textframe?
                  Vamitul Level 4

                  Can't remember when I persueded myself that move parameter suppose to be the same kind of object (IP to IP; char to char and so on)

                  Kind of is, but as usual Javascript does type conversion and sometimes you get lucky and it actually works (in this case it converts Story to Story.insertionPoints[0]).

                  • 6. Re: move table within a textframe?
                    Peter Kahrel Adobe Community Professional & MVP

                    Vamitul -- I don't quite see the type conversion Story > Story.insertionPoints[0]. But I take your point that it's better not to rely on JS's type conversion, maybe like this:

                     

                    var story = app.selection[0].parentStory;
                    var table = story.characters[story.tables[0].storyOffset.index];
                    var target = story.characters[app.selection[0].index];
                    table.move (LocationOptions.BEFORE, target);
                    

                     

                    So that the item to be moved and the target are the same type, here, characters. Or am I missing the point entirely?