Skip to main content
Known Participant
May 5, 2015
解決済み

Is it possible to remove data from cells depending on the content of the neighbouring cells of a Framemaker table?

  • May 5, 2015
  • 返信数 1.
  • 1504 ビュー

Is it possible to remove data from cells depending on the content of the neighbouring cells of a Framemaker table?

Below is a very basic example of the predicament I have. I have hundreds of tables that I need to edit. They contain data in rows of two as below, and are separated by a black row between each pair. The top row always has four variations but for the sake of simplicity in this example it can be either "1" or "2", 2 variations. I want to know if its possible to write a script that will allow me to remove "A" from the cells that have a "2" in the neighbouring cells (immediately above) and retain "A" in all cells with a "1" immediately above. As clear as mud right?

Any help is greatly appreciated, I'm pretty much a total newbie.

112111
AAAAAA
111212
AAAAAA
121111
AAAAAA
112112
AAAAAA
このトピックへの返信は締め切られました。
解決に役立った回答 frameexpert

From a given cell, you can also navigate to the cells above and below.

// Given the cell containing the insertion point...

var doc = app.ActiveDoc;

var pgf = doc.TextSelection.beg.obj;

var cell = pgf.InTextObj;

// ...navigate down the column.

while (cell.ObjectValid () === 1) {

  // Do something here.

  // ...

  cell = cell.CellBelowInCol;

}

// ...navigate up the column.

while (cell.ObjectValid () === 1) {

  // Do something here.

  // ...

  cell = cell.CellAboveInCol;

}

返信数 1

frameexpert
Community Expert
Community Expert
May 5, 2015

Yes, this is absolutely possible and should be practical. First, you need a function to read the text in the cells. Search this forum for a function called getText; I am sure I have posted it at least once. Then you need to be able to navigate from cell-to-cell. There are several ways to do this, but here is how you can do it row-by-row. -Rick

#target framemaker

var doc = app.ActiveDoc;

// Set a variable for the table containing the insertion point.

var tbl = doc.SelectedTbl;

// Navigate row by row.

var row = tbl.FirstRowInTbl, cell;

while (row.ObjectValid () === 1) {

   cell = row.FirstCellInRow;

   while (cell.ObjectValid () === 1) {

     // Do something here.

     // ...

     cell = cell.NextCellInRow;

   }

   row = row.NextRowInTbl;

}

www.frameexpert.com
che47audio作成者
Known Participant
May 5, 2015

Great news! Thanks Rick, I'll have a crack with this and update with any progress.

frameexpert
Community Expert
frameexpertCommunity Expert解決!
Community Expert
May 5, 2015

From a given cell, you can also navigate to the cells above and below.

// Given the cell containing the insertion point...

var doc = app.ActiveDoc;

var pgf = doc.TextSelection.beg.obj;

var cell = pgf.InTextObj;

// ...navigate down the column.

while (cell.ObjectValid () === 1) {

  // Do something here.

  // ...

  cell = cell.CellBelowInCol;

}

// ...navigate up the column.

while (cell.ObjectValid () === 1) {

  // Do something here.

  // ...

  cell = cell.CellAboveInCol;

}

www.frameexpert.com