23 Replies Latest reply on Feb 9, 2014 3:33 PM by Trevorׅ

    [AS] How to test the presence of at least one table?

    Olivier Berquin

      Hello everyone,

       

       

      I would like to test for the presence of at least one table in a document before starting a process (on edge strokes). 

       

      I found this, but I do not know if this is really effective:

                                    set CountOfTables1 to count of tables of every story

                                    set CountOfTables2 to every table of every story

       

      The first gives me a list of the number of table in each story; the second gives me the objects reference of every table.

       

      Is there another way?

       

      TIA.

       

      Oli.

        • 1. Re: [AS] How to test the presence of at least one table?
          Laubender Adobe Community Professional & MVP

          @Olivier – don't know much about AppleScript, but have some experience in ExtendScript.

           

          From that I can say that the Story object is absolutely the right target if you are looking for tables.

          Also Story objects inside nested objects are detected: Story objects in groups, MSOs, buttons, hidden objects etc.pp.

           

          And if your goal is just to detect if at least one table is present in the document, I'll go for the second method and read out its length. Very efficient.

           

          Uwe

          • 2. Re: [AS] How to test the presence of at least one table?
            Olivier Berquin Level 1

            Thank you.

            I see no alternative but to "store" each table.

            It's pitty ... I have a document (an annual report) that contains nearly 200 tables. It takes time to store them.

             

            Oli.

            • 3. Re: [AS] How to test the presence of at least one table?
              Laubender Adobe Community Professional & MVP

              @Olivier – talking about time, what do you consider too much time?

              And: how long does it take your script?

               

              If I'll do something like this in ExtendScript for, let's say a 500 pages document with about 1,300 tables, it will take about 6 seconds. And I'm on an five years old MacBook Pro.

               

              ExtendScript:

               

              start_time = Date.now();
              
              var tableLengthOfDocument = app.documents[0].stories.everyItem().tables.everyItem().getElements().length;
              
              end_time = Date.now();
              elapsed_time = ((end_time - start_time)/1000)/60;
              
              alert(elapsed_time+" minutes"+"\r"+tableLengthOfDocument+" tables in document");
              

               

              Uwe

               

              Message was edited by: Laubender

              • 4. Re: [AS] How to test the presence of at least one table?
                Laubender Adobe Community Professional & MVP

                @Olivier – on the other hand, it could be faster to loop through all storys of that document reading out the length of the tables. And stop, if you hit the first table.

                 

                ExtendScript:

                 

                //EDIT: A bug creeped in the original version of my ExtendScript.

                 

                Here the tested script:

                 

                var s=app.documents[0].stories;
                var myAlert = 0;
                
                for(var n=0;n<s.length;n++){
                    
                    var currentStory = s[n];
                    
                    
                    if(currentStory.tables.length > 0){
                        myAlert = 1;
                        break;
                        };
                
                    };
                
                end_time = Date.now();
                elapsed_time = ((end_time - start_time)/1000)/60;
                
                if(myAlert){
                    alert(elapsed_time+" minutes"+"\r"+"At least ONE table found.");
                    };
                else{
                    alert(elapsed_time+" minutes"+"\r"+"NO table found.");
                    };
                

                 

                In my case with the 1,300 tables in about 1,500 story objects it took that script a split second to detect a table.

                But this could vary, depending on your count of story objects. In my case nearly all story objects contain at least one table.

                 

                Uwe

                 

                Message was edited by: Laubender

                 

                Message was edited by: Laubender

                • 5. Re: [AS] How to test the presence of at least one table?
                  Laubender Adobe Community Professional & MVP

                  @Olivier – or, if you assume, that nearly every story contains a table, you could split the task in two sections:

                   

                  1. Count on stories.anyItem() and check for tables (let InDesign decide which arbitrary one single story anyItem() will reach)

                  2. If that will fail, loop through all stories

                   

                  In comparison with a single loop through all the story objects, this could be even more efficient. Or not, adding a small penalty for taking its time, if the ratio "number of story objects containing a table" vs. "number of story objects" is very low.

                   

                  Here an example for an ExtendScrpt using anyItem():

                   

                  start_time = Date.now();
                  
                  var s=app.documents[0].stories;
                  var myAlert = 0;
                  
                  var myResult = detectATable();
                  
                  function detectATable(){
                  
                      //Use anyItem() 
                      //to single out an arbitrary story in the document:
                  
                      if(s.anyItem().tables.length > 0){
                          myAlert = 1;
                          };
                  
                      //If by chance a story with a table is found
                      //end this function and return a result:
                  
                      if(myAlert){return myAlert};
                  
                      //If not (sigh!) do the walk through a loop with all story objects:
                  
                      for(var n=0;n<s.length;n++){
                  
                          var currentStory = s[n];
                  
                  
                          if(currentStory.tables.length > 0){
                              myAlert = 1;
                              break;
                              };
                  
                          };
                  
                      return myAlert;
                  };
                  
                  end_time = Date.now();
                  elapsed_time = ((end_time - start_time)/1000)/60;
                  
                  if(myResult === 1){
                      alert(elapsed_time+" minutes"+"\r"+"At least ONE table found.");
                      };
                  else{
                      alert(elapsed_time+" minutes"+"\r"+"NO table found.");
                      };
                  

                   

                  Uwe

                  1 person found this helpful
                  • 6. Re: [AS] How to test the presence of at least one table?
                    Olivier Berquin Level 1

                    Thanks, Uwe, for all these tests, very helpful.

                     

                    Oli.

                    • 7. Re: [AS] How to test the presence of at least one table?
                      Marc Autret Level 4

                      @ Uwe

                       

                      Very clever use of anyItem().

                       

                      @ Olivier

                       

                      Uwe's approach is undoubtedly the fastest.

                      Now, if you need to compute the exact number of tables the document contains, you can take advantage of the U+0016 encoding of table anchors and then invoke myDoc.findText() as shown below:

                       

                      function countTables()
                      {
                          app.findTextPreferences = null;
                          app.findTextPreferences.findWhat = "\x16";
                          var t = app.properties.activeDocument||0;
                          return t&&t.findText().length;
                      };
                      
                      alert( countTables() );
                      

                       

                       

                      @+

                      Marc

                      1 person found this helpful
                      • 8. Re: [AS] How to test the presence of at least one table?
                        Trevorׅ Adobe Community Professional

                        Hi all,

                         

                        I didn't do any compartive test but I can't see where this simple method would fail in speed or accuracy.

                        Dosen't seem to have any problems with nesting or anything else.

                        Should even work on CC9.2 ;-) (not tested)

                         

                        if (!app.properties.activeDocument) {alert ("Really!?"); exit()};
                        var doc = app.activeDocument,
                              t = doc.stories.everyItem().tables.length;
                        alert ((t) ? t + " Table" + ((t>1) ? "s" : "") : "Diddlysquat");
                        

                         

                        Regards,

                         

                        Trevor

                        1 person found this helpful
                        • 10. Re: [AS] How to test the presence of at least one table?
                          Laubender Adobe Community Professional & MVP

                          @Marc – the question is: could we do something more to speed up the process  using anyItem() ?

                           

                          What, if we set up a loop for the length of all Story objects using anyItem() to test for tables?

                           

                          1. Would anyItem() use a particular Story object more than one time?


                          After some tests, I know: yes, that would be the case. But not that often.

                          So we need our proven fall back mechanism and loop through all items of the Story objects in case anyItem() would fail.

                           

                          2. Could it be faster than using anyItem() only once PLUS looping through all items?

                           

                          Not always, but often or at least sometimes. I cannot provide hard facts on this.

                           

                          See the following test using anyItem() more extensively.
                          Best run from the ESTK because the result is written to its JavaScript Console.

                           

                          //DetectANYtable_using_anyItem()_EXTENSIVELY.jsx
                          //Uwe Laubender
                          
                          //DESCRIPTION:Best run in ESTK because result is written to its console
                          
                          var startTime = Date.now();
                          
                          var myResult = atLeastOneTableInDoc(app.documents[0]);
                          
                          var endTime = Date.now();
                          var elapsedTimeInMinutes = ((endTime - startTime)/1000)/60;
                          
                          $.writeln(myResult+"\t"+elapsedTimeInMinutes);
                          exit();
                          
                          //RESULTS:
                          
                          // 0    NO table detected
                          // 1    YES, at least one table detected by anyItem()
                          
                          // 2*   YES, table detected by regular loop through all Story objects if anyItem() fails
                          
                          // * It seems that this result is highly unlikely, but that depends on the test document.
                          
                          
                          
                          
                          //FUNCTION USING anyItem() EXTENSIVELY:
                          
                          function atLeastOneTableInDoc(myDoc){
                          
                              var myResult = 0;
                              if(myDoc.stories.length === 0){return myResult};
                          
                              var myStories = myDoc.stories;
                          
                              //LOOP length == length of all Story objects
                              //using anyItem() for checking length of Table objects
                          
                              for(var n=0;n<myStories.length;n++){
                          
                                  if(myStories.anyItem().tables.length > 0){
                                      myResult = 1;
                                      return myResult;
                                      };
                          
                                  };
                          
                              //FALL-BACK, if anyItem() will fail:
                          
                          //EDIT:    if(!myResult){
                                  for(var n=0;n<myStories.length;n++){
                          
                                      if(myStories[n].tables.length > 0){
                                          myResult = 2;
                                          return myResult;
                                          };
                          
                                      };
                          //EDIT:       };
                          
                              return myResult;
                          
                          }; //END function atLeastOneTableInDoc(myDoc)
                          

                           

                           

                          Or would it be wise to loop anyItem(), say, only a one-tenth of all Story objects? Or one-fifth of all Story objects?

                          Could be. Only time would tell… ;-)

                           

                          Uwe

                           

                          Message was edited by: Laubender – The if-statement before the second loop is *not* necessary.

                          • 11. Re: [AS] How to test the presence of at least one table?
                            Olivier Berquin Level 1

                            Marc,

                             

                            I did not know that the tables had a "anchor table".

                             

                             

                            Trevor,

                            Your script is very effective and very fast

                             

                             

                            Thank you everyone for your help.

                            This forum is followed by highly proficient people.

                             

                            Oli.

                            • 12. Re: [AS] How to test the presence of at least one table?
                              Laubender Adobe Community Professional & MVP

                              @Trevor – you might have missed #3, but your approach is faster than the script in #3.

                               

                              I think It's because I resolved tables.everyItem() with getElements().

                               

                              I'd say it could be well a race head-to-head  between my approach with anyItem() and yours. :-)

                               

                              Uwe

                              • 13. Re: [AS] How to test the presence of at least one table?
                                Marc Autret Level 4

                                Hi all,

                                 

                                Uwe:

                                > Would anyItem() use a particular Story object more than one time?

                                > After some tests, I know: yes, that would be the case. But not that often.

                                 

                                1. Using anyItem() seems a good optimization approach in that it randomly selects one item among many. One could argue against that strategy, that there is no serious reason to prefer a random item to—say—the first one, or the last one, or the middle one, in the collection. But I still consider anyItem() offers a chance to reach faster, on average, a good candidate. Point #1: first and last items are certainly not good candidates in a publication structure, because of the non-usual form, on average, of introduction stuff, copyright notices, summaries, index, colophon, and so on. Point #2: the middle item is certainly as promising as any random element, except that, given a document, the middle item is determined, meaning that if it's a wrong candidate the script will constantly select that wrong candidate when working on that document.

                                 

                                2. That said, using anyItem() in a loop may lead to lose the benefit of the strategy above. As we know, what is critically time consuming in ExtendScript is DOM accesses. The more you hit or resolve DOM specifiers, the less your routine goes fast. From this standpoint, Trevor's approach—based on myDoc.stories.everyItem().tables.length—has a serious advantage, as long as we don't need to keep the receivers into a JS Array. What would be really interesting here would be to benchmark anyItem() vs. everyItem() in various cases. (What about doc.stories.everyItem().tables.anyItem().isValid? etc.)

                                 

                                Trevor:

                                > Doesn't seem to have any problems with nesting or anything else.

                                 

                                Really? To my knowledge doc.stories.everyItem().tables can't reach nested tables (tables inside tables) and will also ignore tables inside footnotes.

                                By contrast, capturing U+0016 via doc.findText() will return all table refs that the doc may contain at any location. But as already said this is a slower method, since findText() can only run in a comprehensive way. (Unfortunately.)

                                 

                                @+

                                Marc

                                • 14. Re: [AS] How to test the presence of at least one table?
                                  Trevorׅ Adobe Community Professional

                                  Marc

                                   

                                  The test I did for nested tables stank (table pasted in rectangle and that rectangle pasted in a table ).  It does not work for nested tables

                                  I tested .isValid and it's a lot slower.

                                   

                                  Uwe

                                   

                                  Yes, I noticed that difference after posting my eeakk comment.

                                  Using slice(0) after the getElements can make a big difference but still the simple length going to be quicker in this case.

                                  Also the getElements without the slice(0) will return "too many elements" if there are to many elements (between 1500 - 15,000).

                                   

                                  On the other hand for repeated access of the variable (looping) it's as know normally quicker to use the getElements().slice(0).length than just length

                                   

                                  In summary

                                   

                                  1) Your anyItem() method is going to be very quick on a document which has a high ratio of stories containing tables.

                                  2) Although your method could and possibly probably be 100 times quicker than mine I would definitely use my method in terms of typing time and space verses the 1/2 second it might save on execution time per 10,000 tables.

                                  3) The only accurate method (in this thread) for counting the tables including nested and footnotes is Marc's Grep method.

                                   

                                  So I guess the 3 of us can share first place.

                                   

                                  I just wonder if using the same technique as Marc used in our discussion sometime back on nested buttons might get to a quick count than using the Grep method here.

                                   

                                  Clearly needs to be repeated on different types of document setups one can try the below

                                   

                                   

                                  if (!app.properties.activeDocument) {alert ("Really!?"); exit()};
                                  var scriptCount = 1;
                                  
                                  
                                  // Script 1 table.length
                                  var doc = app.activeDocument,
                                        start = Date.now(),
                                        t = doc.stories.everyItem().tables.length,
                                        finish = Date.now();
                                  $.writeln ("\rtable.length Script (" + scriptCount++ + ") took " + (finish - start) + "ms\r" + ((t) ? t + " Table" + ((t>1) ? "s" : "") : "Diddlysquat"));
                                  
                                  
                                  // Script 2 getElements
                                  var doc = app.activeDocument;
                                  var start = Date.now();
                                  var t = doc.stories.everyItem().tables.everyItem().getElements().length;
                                  var finish = Date.now();
                                  $.writeln ("\rgetElements Script (" + scriptCount++ + ") took " + (finish - start) + "ms\r" + ((t) ? t + " Table" + ((t>1) ? "s" : "") : "Diddlysquat"));
                                  
                                  // Script 3 getElements.slice(0)
                                  var doc = app.activeDocument;
                                  var start = Date.now();
                                  var t = doc.stories.everyItem().tables.everyItem().getElements().slice(0).length;
                                  var finish = Date.now();
                                  $.writeln ("\rgetElements.slice(0) Script (" + scriptCount++ + ") took " + (finish - start) + "ms\r" + ((t) ? t + " Table" + ((t>1) ? "s" : "") : "Diddlysquat"));
                                  
                                  // Script 4      isValid
                                  var start = Date.now();
                                  var t = doc.stories.everyItem().tables.everyItem().isValid; 
                                  var finish = Date.now();
                                  $.writeln ("\risValid Script (" + scriptCount++ + ") took " + (finish - start) + "ms\rThe document contains " + ((t) ? "tables" : "no tables"));
                                  
                                  
                                  
                                  // Script 5   Marc's Grep 
                                  var start = Date.now();
                                  var t = countTables(); 
                                  var finish = Date.now();
                                  $.writeln ("\rMarc's Grep Script as said only accurate one but slow (" + scriptCount++ + ") \rtook " + (finish - start) + "ms\r" + ((t) ? t + " Table" + ((t>1) ? "s" : "") : "Diddlysquat"));
                                  
                                  
                                  
                                  // Script 6 very lot of anyItem
                                  
                                  var start = Date.now();
                                  var myResult = atLeastOneTableInDoc(app.documents[0]);
                                  var finish = Date.now();
                                   $.writeln ("\rUwes Anyone for Bingo Script (" + scriptCount++ + ") took " + (finish - start) + "ms\rThe document contains " + ((myResult) ? "tables" : "no tables"));
                                  
                                  
                                  // Script 7 anyItem length
                                  var start = Date.now();
                                  var myResult = detectATable();
                                  var finish = Date.now();
                                  
                                  $.writeln ("\ranyItem length Script (" + scriptCount++ + ") took " + (finish - start) + "ms\rThe document contains " + ((myResult) ? "tables" : "no tables"));
                                  
                                  
                                  // Script 8 anyItem elements length
                                  var start = Date.now();
                                  var myResult = detectATable2();
                                  var finish = Date.now();
                                  
                                  $.writeln ("\ranyItem elements length Script (" + scriptCount++ + ") took " + (finish - start) + "ms\rThe document contains " + ((myResult) ? "tables" : "no tables"));
                                  
                                  
                                  
                                  
                                  
                                  
                                  //FUNCTION USING anyItem() EXTENSIVELY:
                                  function atLeastOneTableInDoc(myDoc){
                                  
                                      var myResult = 0;
                                      if(myDoc.stories.length === 0){return myResult};
                                  
                                      var myStories = myDoc.stories;
                                  
                                      //LOOP length == length of all Story objects
                                      //using anyItem() for checking length of Table objects
                                  
                                      for(var n=0;n<myStories.length;n++){
                                  
                                          if(anyStory = myStories.anyItem().tables.length > 0){
                                              myResult = 1;
                                              return myResult;
                                              };
                                  
                                          };
                                  
                                      //FALL-BACK, if anyItem() will fail:
                                  
                                  //EDIT:    if(!myResult){
                                          for(var n=0;n<myStories.length;n++){
                                  
                                              if(myStories[n].tables.length > 0){
                                                  myResult = 2;
                                                  return myResult;
                                                  };
                                  
                                              };
                                  //EDIT:       };
                                  
                                      return myResult;
                                  
                                  }; //END function atLeastOneTableInDoc(myDoc)
                                  
                                  
                                  
                                  function detectATable(){
                                      s=app.documents[0].stories;
                                       if(s.anyItem().tables.length){
                                          return true; // Bingo
                                          };
                                     for(var n=0;n<s.length;n++){
                                          if(s[n].tables.length) return true
                                          }
                                      return false
                                  };
                                  
                                  
                                  
                                  function detectATable2(){
                                      s=app.documents[0].stories;
                                       if(s.anyItem().tables.length){
                                          return true; // Bingo
                                          };
                                      var sl = app.documents[0].stories.everyItem().getElements().slice(0);
                                     for(var n=0;n<s.length;n++){
                                          if(s[n].tables.length) return true
                                          }
                                      return false
                                  };
                                  
                                  function countTables()
                                  {
                                      app.findTextPreferences = null;
                                      app.findTextPreferences.findWhat = "\x16";
                                      var t = app.properties.activeDocument||0;
                                      return t&&t.findText().length;
                                  };
                                  

                                   

                                  P.s.

                                   

                                  Marc,

                                  A bit of homework. I didn't test it on the above but I found the your highRes function trimmer seems to have a large favoritism to the first function to compare.

                                  I was testing 2 prototypes and swapping the order swapped the result. One can make the prototypes the same and see the time difference.

                                  • 15. Re: [AS] How to test the presence of at least one table?
                                    Marc Autret Level 4

                                    @ Trevor

                                     

                                    You mean the comparePerf.js script? Yep, noticed those unexpected variations in various circumstances

                                    Benchmarking InDesign scripts is definitely a challenge, at least when scripting DOM is involved. I suspect the subsystem uses caching strategies and probably 'idle event'-driven processes so that timing code becomes highly non-deterministic!

                                     

                                    @+

                                    Marc

                                     

                                    NB. Just a correction: Grep is not used in my method, it's the regular findText(). Makes no difference in your conclusion anyway.

                                    • 16. Re: [AS] How to test the presence of at least one table?
                                      Trevorׅ Adobe Community Professional

                                      Yep that's the one.

                                      I haven't used it for some time but it might help to do something like a combination of

                                      a) Put the computer to sleep a bit between testing the files {$.sleep(1000)} to give the computer to calm down.

                                      b) Before running the comparison add some function so the computers as busy before running the 1st function as it is before the 2nd

                                      c) Instead of running the 1st function say 100 time and then the second one 100 times have the script run 4 times each time alternating which function is to be run 1st and on each of those 4 time have the 2 functions run alternating f1 f2 f1 f2 f1 f2 and so on. (could get complicated for comparing more than 2 functions.

                                      • 17. Re: [AS] How to test the presence of at least one table?
                                        zeRafio Level 1

                                        Hi all,

                                         

                                        Don't have enough time to read the entire discussin,.

                                        But if the goal is still to know if a doc contains at least one table, try this:

                                         

                                        tell application id "InDn"
                                          
                                                  tell active document
                                                            set a1 to tables of stories
                                                            set a2 to (count of a1) > 1
                                                  end tell
                                          
                                        end tell
                                        
                                        

                                         

                                        It's the fastest way I know.

                                        Takes less than 2 seconds in a 274 pages document containing 1918 stories.

                                         

                                        But I can be beside the point…

                                        • 18. Re: [AS] How to test the presence of at least one table?
                                          Laubender Adobe Community Professional & MVP

                                          @zeRafio – sorry to say, but with some of the solutions presented above we are more in a time frame of 0.1 to 0.01 seconds. Of course depending on the exact amount of stories and "table density" (and the hardware specifications of our equipment).

                                           

                                          Uwe

                                          • 19. Re: [AS] How to test the presence of at least one table?
                                            Dirk Becker Level 4

                                            Can anybody with a big document give the following script a try?

                                            I've added an unfair advantage for AppleScript - using the optional whose clause you can narrow down the examined objects by additional criteria. I just chose a table style to illustrate the principle.

                                             

                                            Dirk

                                             

                                            tell application "Adobe InDesign CS6"

                                                      tell active document

                                                                set tstyle to table style 1

                                                                get exists (table of every story whose applied table style is not tstyle)

                                                      end tell

                                            end tell


                                            • 20. Re: [AS] How to test the presence of at least one table?
                                              Olivier Berquin Level 1

                                              Hi Dirk,

                                               

                                              There is a small error in your script.

                                               

                                              tell application "Adobe InDesign CS6"

                                                        tell active document

                                                                  set tstyle to table style 1

                                                                  get exists (every table of every story whose applied table style is not tstyle)

                                                        end tell

                                              end tell

                                               

                                               

                                              On the other hand, if the user has chosen to only create tables with style "[None]" (I don't know the name of this style in english… something like [No table style]?), your script returns "false" while there has at least one table in the document.

                                               

                                              Olivier.

                                              • 21. Re: [AS] How to test the presence of at least one table?
                                                Marc Autret Level 4

                                                Now here is a way to retrieve then select all tables one-by-one:

                                                 

                                                var getTables = function(a,i)
                                                {
                                                    app.findTextPreferences = null;
                                                    app.findTextPreferences.findWhat = "\x16";
                                                    a=(a=app.properties.activeDocument)?a.findText():[];
                                                    for( i=a.length ; i-- ; a[i]=a[i].tables[0].getElements()[0] );
                                                    return a;
                                                };
                                                
                                                // ---
                                                // Demo : select the tables (delay: 700ms)
                                                // ---
                                                
                                                var tables = getTables(),
                                                    i,
                                                    n = tables.length,
                                                    // ---
                                                    lw = n && app.properties.activeWindow,
                                                    zp0 = lw && lw.zoomPercentage,
                                                    zp1 = (zp0 > 3000 ? -1 : 1) + zp0;
                                                
                                                for( i=0 ; i < n ; ++i )
                                                    {
                                                    try {
                                                        lw.select(tables[i]);
                                                        lw.zoomPercentage = zp1;
                                                        lw.zoomPercentage = zp0;
                                                        }
                                                    catch(_){}
                                                    $.sleep(700);
                                                    }
                                                

                                                 

                                                EDIT: It should be noticed that selecting a table may fail if the table has no visible container (overset contents). That's the reason why I use try…catch.

                                                 

                                                @+

                                                Marc

                                                • 22. Re: [AS] How to test the presence of at least one table?
                                                  Dirk Becker Level 4

                                                  Hi Olivier,

                                                   

                                                  you're right with the missing "every" - I had also tried "any" as I thought it closer to the intention but that did not compile.

                                                  Your change takes my resulting "exists" expression pretty close to your "get elements", it just allows the script subsystem to skip processing after the first found instance, and of course won't transfer all those object specifiers to the AppleScript engine.

                                                   

                                                  As I wrote, the check for the style was just to illustrate the "whose" feature of the AppleScript language - of course in your case you could disregard styles and use a precondition on edge strokes. That way you'd skip all tables that won't need processing.

                                                   

                                                  Dirk

                                                  • 23. Re: [AS] How to test the presence of at least one table?
                                                    Trevorׅ Adobe Community Professional

                                                    Hi Dirk

                                                     

                                                    For large test documents for this sort of purpose I just create a new document of a 1000 or so pages and use doc.pages.everyItem.textFrames.add();

                                                    Don't even need to give geos. Then use itemByRange to add the tables.