4 Replies Latest reply on Jun 28, 2017 4:34 AM by Russ Ward

    How to find out if a paragraph contains a table or not?

    varuns44789478

      Is there any way to find if a paragraph contains a table or not? Can I get a list of objects within a paragraph to determine this?

        • 1. Re: How to find out if a paragraph contains a table or not?
          Russ Ward Level 4

          Hi Varun,

           

          Now your questions are getting harder.   Navigating and manipulating text and text objects is challenging. I can give you some quick tips but you will need to spend time experimenting on your own.

           

          To get a list of anything within a paragraph, you should use the GetText or GetTextForRange method. Both methods return a TextItems array which is tough to figure out at first. Here is a basic function that retrieves all tables (that is, table anchors) within the currently-selected paragraph:

           

          var tr = doc.TextSelection;
          if(tr.beg.obj.ObjectValid())
          {
              var textItems = tr.beg.obj.GetText(Constants.FTI_TblAnchor);
              alert("The current paragraph contains " + textItems.len + " table anchor(s)");
          }
          else alert("No valid selection or insertion point. Cannot look for tables.");
            
          

           

          It is important to remember that tr.beg.obj will be a paragraph object, the paragraph that contains the insertion point or the beginning of the current selection.

           

          The actual table objects are in the textitems array, contained in "obj" members. For example, the first table in the paragraph will be:

           

          textItems[0].obj
          

           

          Here is how you could report the table format:

           

          alert(textItems[0].obj.TblTag);
          

           

          This is the best I can do right now with the time I have. This can get complicated. Expect that it will take some to really figure it out, especially because any sort of explanatory documentation is virtually non-existent.

           

          Russ

          • 2. Re: How to find out if a paragraph contains a table or not?
            varuns44789478 Level 1

            Thank you Russ!

             

            I wanted to just find out if a paragraph contains a table or not and this tell me exactly how to do it. I have just started with FrameMaker Scripting and hence have so many questions. Guess its a good thing my questions are getting harder . I am playing around with developing different scripts iterating through a document/book and manipulating different styles/formats and objects to get a better understanding of the FrameMaker Object Model.

            • 3. Re: How to find out if a paragraph contains a table or not?
              Russ Ward Level 4

              Hi Varun,

               

              That sounds great... I encourage you to continue. The FrameMaker API is one of its great strengths, which paradoxically seems ignored by most users. Unfortunately, documentation is not a great strength of ExtendScript. The FDK documentation is very good, but that's because Adobe clearly dedicated many more resources to it in the past. Often, ExtendScript developers refer to that documentation because it is more informative. In any case, if you can't find it in the book (not unlikely), don't hesitate to ask here.

               

              Russ

              • 4. Re: How to find out if a paragraph contains a table or not?
                Russ Ward Level 4

                By the way, I thought I mentioned this, but maybe not. I have a bunch of free samples for download which I think may help you. You can find them here:

                 

                FrameMaker ExtendScript Samples - West Street Consulting

                 

                Russ