Extract Figure & Table Names From Document
Last April I asked for help counting figures in our documents. The code you helped me with has been a real help. In addition to getting a figure count, I also get a table count. The customer uses these to help determine the level of effort for editing various documents.
Recently, I was asked if it's possible to extract the Title associated with each figure and table. I tried boring down in the data browser, but can't find where that information stored. I'm currently using the following code to get the counts:
function countFigures() {
figureCtr = 0;
var figure = doc.FirstGraphicInDoc;
while (figure.ObjectValid()) {
Alert ('Stop script and check for figure name.');
if (figure.constructor.name === "AFrame") {
figureCtr++;
}
figure = figure.NextGraphicInDoc;
}
return figureCtr;
}
function countTbls() {
tableCtr = 0;
textList = doc.MainFlowInDoc.GetText (Constants.FTI_TblAnchor);
// If you want to loop through all of the tables, you can do this:
count = textList.length;
tableCtr = tableCtr + count;
for (i = 0; i < count; i += 1) {
tbl = textList[i].obj // The table object.
tbl = doc.FirstTblInDoc;
if(tbl.ObjectValid() == false) {
Console(' No tables found!');
}
}
return tableCtr;
}Was hoping it would be as simple as doc.FirstGraphicInDoc.Name would work, but it's obviously not that simple. As always. Any suggestions very much appreciated.
