Skip to main content
gisteppen
Known Participant
February 14, 2014
Answered

How to access a table for changes

  • February 14, 2014
  • 1 reply
  • 1360 views

I'm iterating through the Pgf objects in a flow, and for each one I look for table anchors. I find the table anchor, then what do I do to access its Tbl object and do things with it? I'm just trying to find out if there are any changebars in the table. I don't think using Doc.FirstTblInDoc will help me because I'm starting with a TblAnchor text item.

I run this code on a doc that has only one paragraph with a table anchor in it:

function test() {

    doc = app.ActiveDoc;

    var pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

    while ( pgf.ObjectValid() ) {

    var textitems = pgf.GetText(Constants.FTI_TblAnchor);

    var aa = textitems[0];

    Console('what is this: '+aa);

    pgf = pgf.NextPgfInFlow;

    }

}

This prints "what is this: [object TextItem]".

Seems like I should be able to do something like this to get the Tbl object:

myTable = textitems[0].idata;

Am I warm? Once I get the Tbl object, I'm hoping it's a simple matter of using GetText to get changes, then finding a changebar.

Thanks,

Mark

This topic has been closed for replies.
Correct answer frameexpert

This should give you the Tbl (table) object:

myTable = textItems[0].obj;

1 reply

frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
February 14, 2014

This should give you the Tbl (table) object:

myTable = textItems[0].obj;

www.frameexpert.com
Legend
February 14, 2014

Rick, interesting. I would have thought to use .idata. For .idata, the documentation says:

ID of the object if the text item is an object,.

...then it says something cryptic for .obj. Seems I've used .idata in the past for objects. But I could be wrong, just pointing this out.

Mark, once you have the table object, you'll need to iterate over each cell and execute getText() on each. You can't get the text for a whole table at once.

Russ

frameexpert
Community Expert
Community Expert
February 14, 2014

Hi Russ, I just checked some of my code and it is obj. Here is how I navigate all of the tables in the document's main flow:

var tbl = 0, textList = 0, i = 0;

textList = doc.MainFlowInDoc.GetText(Constants.FTI_TblAnchor);

for (i = 0; i < textList.length; i += 1) {

  tbl = textList.obj;

  // Process the table here.

}

www.frameexpert.com