How to find out if a paragraph contains a table or not?
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?
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?
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
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.