Highlighted

Script to sort table in ascending order

New Here ,
Aug 01, 2016

Copy link to clipboard

Copied

Hi,

I am not able to find any frame maker function to sort the table in ascending order with respect to column 1. Please, guide me how I can write the extended script in frame maker to sort the table.

Thanks & Regards

Lohith

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Here is how you can sort a table with ExtendScript:

#target framemaker

var doc = app.ActiveDoc;

// Set a variable for the selected table.

var tbl = doc.SelectedTbl;

// Select the table.

tbl.MakeTblSelection (Constants.FF_SELECT_WHOLE_TABLE);

// Sort the table.

CallClient ("TableSort", "row nocase 0 ascending -1 ascending -1 ascending");

Here is information from the FDK Programmers Reference for the TableSort parameters:

TOPICS
Scripting

Views

1.4K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Script to sort table in ascending order

New Here ,
Aug 01, 2016

Copy link to clipboard

Copied

Hi,

I am not able to find any frame maker function to sort the table in ascending order with respect to column 1. Please, guide me how I can write the extended script in frame maker to sort the table.

Thanks & Regards

Lohith

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Here is how you can sort a table with ExtendScript:

#target framemaker

var doc = app.ActiveDoc;

// Set a variable for the selected table.

var tbl = doc.SelectedTbl;

// Select the table.

tbl.MakeTblSelection (Constants.FF_SELECT_WHOLE_TABLE);

// Sort the table.

CallClient ("TableSort", "row nocase 0 ascending -1 ascending -1 ascending");

Here is information from the FDK Programmers Reference for the TableSort parameters:

TOPICS
Scripting

Views

1.4K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 01, 2016 0
Advocate ,
Aug 02, 2016

Copy link to clipboard

Copied

Hi, Lohith,

I do not understand Your question, because there is the menu Table > Sort:

table-sort.png

I have set in the dialogue to sort at first by the first column, then by the second. If there are no heading rows then the drop-down list mention the columns by "1st column" etc.

table-sort2.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2016 0
New Here ,
Aug 02, 2016

Copy link to clipboard

Copied

Hi K.Daube,

I know how to sort a table in Frame Maker but I need ESTK script to sort a table.

I am creating a macro for one of my application using ESTK script. In that script, I want to sort a table, for that I need ESTK script to sort the table.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2016 0
Adobe Community Professional ,
Aug 02, 2016

Copy link to clipboard

Copied

Here is how you can sort a table with ExtendScript:

#target framemaker

var doc = app.ActiveDoc;

// Set a variable for the selected table.

var tbl = doc.SelectedTbl;

// Select the table.

tbl.MakeTblSelection (Constants.FF_SELECT_WHOLE_TABLE);

// Sort the table.

CallClient ("TableSort", "row nocase 0 ascending -1 ascending -1 ascending");

Here is information from the FDK Programmers Reference for the TableSort parameters:

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2016 0
New Here ,
Aug 02, 2016

Copy link to clipboard

Copied

Hi Frameexpert,

Thank you very much for your response.

your code is working fine only when you have the curser inside the table.

If I put the curser outside the table, it gives a alert message "? No table has been selected. Please select a table and try again."

Please guide me how can resolve this .

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2016 0
Advocate ,
Aug 02, 2016

Copy link to clipboard

Copied

Lohith,

Instead of using doc.SelectedTbl you need to find your target table via the list of tables in your document. Start with doc.FirstTblInDoc and walk through the linked list until you find the table to sort. Then execute the sort code on it.

Jang

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2016 0
New Here ,
Aug 03, 2016

Copy link to clipboard

Copied

Hi Jang,

Thanks a lot for your information. Its Working...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2016 0