-
1. Re: Scripting tips
Arnis Gubins May 7, 2014 12:24 PM (in response to frameexpert)Hi Rick,
Great advice. I'll also add that posters should mention which version of FM that they are using and what platform they are running on. [Older versions of Extendscript had numerous issues]
Also, for those reading this thread for the first time, please use the "Correct Answer" link when your problem has been solved so that others can be see that a solution exists and to give credit to who helped you out.
-
2. Re: Scripting tips
frameexpert May 7, 2014 12:42 PM (in response to frameexpert)Here is a good place to start. Someone recently asked for help applying a condition format to certain paragraphs. When working on paragraphs, first get your code working on the paragraph containing the insertion point. Here is a useful snippet for doing that:
// Set a variable for the active document. var doc = app.ActiveDoc; // Get the paragraph at the beginning of the selection or insertion point. var pgf = doc.TextSelection.beg.obj; // Do something with the paragraph here: // ...
Here is code you can use for working on the selected table, or the table containing your text cursor:
// Set a variable for the active document. var doc = app.ActiveDoc; // Get the table currently selected or that contains the insertion point. var tbl = doc.SelectedTbl; // Do something with the table here: // ...
Do you need to work on table cells? Here is how to isolate the cell object that contains your text cursor.
// Set a variable for the active document. var doc = app.ActiveDoc; // Get the paragraph that contains the insertion point. var pgf = doc.TextSelection.beg.obj; // Get the table cell that contains the paragraph. var cell = pgf.InTextObj; // Do something with the cell here: // ...
Or, find the row that contains the cell where your text cursor is:
// Set a variable for the active document. var doc = app.ActiveDoc; // Get the paragraph that contains the insertion point. var pgf = doc.TextSelection.beg.obj; // Get the table cell that contains the paragraph. var cell = pgf.InTextObj; // Get the row that contains the cell. var row = cell.CellRow; // Do something with the row here: // ...
-
3. Re: Scripting tips
snipppyBishop May 13, 2014 4:26 PM (in response to frameexpert)Thank you for the helpful suggestions, Rick. I'm new to scripting, as you know, so helpful tips are very appreciated!



