5 Replies Latest reply on Jan 24, 2017 4:19 AM by Laubender

    "Invalid object for this request" error while placing a image in table cell.

    sumit.bhingardive

      I am having a problem while placing a image inside table cell, in case there is a overflow in the table. The cell in which i am placing the image is not visible in InDesign because the frame containing the table is smaller in size.

       

      var oTable = oTextFrame.parentStory.tables[0]; 
      var cells = oTable.cells;
      for (var iCell = 0; iCell < cells.length; iCell++) { 
      var oCell = cells[iCell];
      oCell.convertCellType(CellTypeEnum.GRAPHIC_TYPE_CELL);
      oCell.rectangles[0].place("D:/Test.jpg");// Here i am getting error "Invalid object for this request".
      }
      
      

       

      I have also checked "isValid" for the rectangle.

        • 1. Re: "Invalid object for this request" error while placing a image in table cell.
          Loic.Aigon Adobe Community Professional

          Your code works fine. Does the file  "D:/Test.jpg" exists ?

          Isn't the jpg- file corrupted ?

           

          What if you want to place it manually ?

           

          Maybe force type to File:

           

          var f = File ( "D:/Test.jpg" );

          $.writeln ( "not valid" );

          oCell.rectangles[0].place( f )

          • 2. Re: "Invalid object for this request" error while placing a image in table cell.
            sumit.bhingardive Level 1

            Hi Loic.Aigon.

             

            Yes the file exists and it is not corrupted. Before executing the code table looks as below:Table1.PNG

            After that i have reduced the container frame size to smaller. Such that only one row is visible.Table2.PNG

            Now I have executed my code to place images. After that the table look like below. Table3.PNG

            After expanding the container frame table looks as below:

            Table4.PNG

             

            As you can see in the above image (Image-3) for first row images are getting generated properly. There are four rows in my table, three more rows are present in table exactly identical to first row, but they are not visible because of container frame over flow. Using my code i am trying to place image for all cells but for other three rows image is not getting placed instead throwing error.

            • 3. Re: "Invalid object for this request" error while placing a image in table cell.
              Loic.Aigon Adobe Community Professional

              Well obviously you have answered to your own question. A simple test shows that indeed, if any of the cell is hidden, the graphic inclusion won't work (throwing your error).

              So it's not your code as it which is faulty, just the indesign inner code.

               

              Your problem here is to expand the table so a cell isn't hidden and can be filled with a graphic.

               

              And FWIW, I noticed your table is xml tagged, so I wanted to autotag the table (with graphics) to see what the xml structure looks like (in order to maybe use xml import as trick) but when I clicked on autotag, it just…crashed. So I guess this feature has not to be used in a xml workflow.

              • 4. Re: "Invalid object for this request" error while placing a image in table cell.
                sumit.bhingardive Level 1

                Yes you are right that if I will expand my table (container frame) my code will work. My use case was to place the images without expanding the container frame.

                 

                That means it is not possible to place a image on the cell without expanding the container frame.

                 

                About xml tag it was just some thing else I was trying on the table. It is not related to my scenario. Thanks.

                • 5. Re: "Invalid object for this request" error while placing a image in table cell.
                  Laubender Adobe Community Professional & MVP

                  sumit.bhingardive wrote:

                  My use case was to place the images without expanding the container frame.

                  That means it is not possible to place a image on the cell without expanding the container frame.

                  Hi Sumit,

                  I did not test this, but I think it is possible to:

                  1. Place the image in a table cell where you know it is visible.

                  2. Select the cell by the select() method

                  3. Copy the cell with app.copy()

                  4. Select a cell in the overflow part of the table

                  5. Paste the clipboard contents

                   

                  Though I did not test this with cells with cellType CellTypeEnum.GRAPHIC_TYPE_CELL …

                  But I can remember that one is able to select CellTypeEnum.TEXT_TYPE_CELL cells in overflow and paste in contents from the clipboard. If this is working there is no need to expand the text frame or to add text frames for showing all rows of the table.

                   

                  Regards,

                  Uwe