Skip to main content
hamdifem
Inspiring
September 19, 2014
Answered

Can you help me about this script

  • September 19, 2014
  • 2 replies
  • 401 views

I wrote the script in the first frame that always creates

I want This process the selected paragraph or paragraphs are created in



var myDocument = app.documents.item (0);

var myStory = myDocument.stories.item (0);

var myTable = myStory.insertionPoints.item (-1) .tables.add ();

myTable.columnCount = 6;

myTable.bodyRowCount = 7;

myTable.topBorderStrokeWeight = 0;

myTable.bottomBorderStrokeWeight = 0;

myTable.leftBorderStrokeWeight = 0;

myTable.rightBorderStrokeWeight = 0;

myTable.cells.everyItem () topEdgeStrokeWeight = 0.;

myTable.cells.everyItem () leftEdgeStrokeWeight = 0.;

myTable.cells.everyItem () topInset = 0.;

myTable.cells.everyItem () leftInset = 0.;

myTable.cells.everyItem () rightInset = 0.;

myTable.cells.everyItem () bottomInset = 0.;

myTable.columns.item (1) .cells [0] .bottomEdgeStrokeWeight = 0.5;

myTable.columns.item (3) .cells [0] .bottomEdgeStrokeWeight = 0.5;

myTable.columns.item (5) .cells [0] .bottomEdgeStrokeWeight = 0.5;

myTable.cells.everyItem () özellikleri = {Otomatik büyüme: true, genişliği: "10 mm", yükseklik: "5 mm"}.;

myTable.columns.item (0) .cells [0] .properties = {Otomatik büyüme: true, genişlik: "5 mm", yükseklik: "4 mm"};

myTable.columns.item (0) .cells [1] .properties = {Otomatik büyüme: true, genişlik: "5 mm", yükseklik: "2 mm"};

myTable.columns.item (2) .cells [1] .properties = {Otomatik büyüme: true, genişlik: "5 mm", yükseklik: "2 mm"};

myTable.columns.item (4) .cells [1] .properties = {Otomatik büyüme: true, genişlik: "5 mm", yükseklik: "2 mm"};

myTable.columns.item (0) .cells [6] .properties = {Otomatik büyüme: true, genişlik: "5 mm", yükseklik: "3 mm"};

myTable.cells [1] .contents = "Ben";

myTable.cells [3] .contents = "II";

myTable.cells [5] .contents = "III";

myTable.columns.item (0) .cells [2] = .contents "A)";

myTable.rows.item (2) .bottomInset = 3;

myTable.columns.item (0) .cells [3] .contents = "B)";

myTable.rows.item (3) .bottomInset = 3;

myTable.columns.item (0) .cells [4] .contents = "C)";

myTable.rows.item (4) .bottomInset = 3;

myTable.columns.item (0) .cells [5] .contents = "M)";

myTable.rows.item (5) .bottomInset = 3;

myTable.columns.item (0) .cells [6] .contents = "E)";

This topic has been closed for replies.
Correct answer Laubender

Change this:

var myDocument = app.documents.item (0);

var myStory = myDocument.stories.item (0);

var myTable = myStory.insertionPoints.item (-1) .tables.add ();

To that:

var myTable = app.selection[0].texts[0].insertionPoints.item(-1).tables.add();

It will add a table at the last insertion point of your text selection.

(I did not include a check, if the selection is a valid text object)

Uwe

2 replies

Jump_Over
Legend
September 19, 2014

Hi,

Find below logic:

1. create tableFormat(mTable) function to group your formats into. I.e. like this:

function tableFormat(mTable) { 

     myTable.columnCount = 6;

     myTable.bodyRowCount = 7;

//... all the rest

     myTable.rows.item (5) .bottomInset = 3;

     myTable.columns.item (0) .cells [6] .contents = "E)";

     }


2. call this function for chosen target. I. e. like this:

var

     mTarget,

     mSelection = app.selection[0],

    len = 0;


if ( mSelection.hasOwnProperty("paragraphs") )

     len = mSelection.paragraphs.length;

while (len-->0) {

     mTarget = mSelection.paragraphs[len].insertionPoints[-1].tables.add ();

     tableFormat(mTarget) ;

     }

function tableFormat(mTable) {

     //...your format orders

     }


Watch backward looping while modifying contents of your "loop area".


Jarek

    

PS. Ups... Uwe was faster 

LaubenderCommunity ExpertCorrect answer
Community Expert
September 19, 2014

Change this:

var myDocument = app.documents.item (0);

var myStory = myDocument.stories.item (0);

var myTable = myStory.insertionPoints.item (-1) .tables.add ();

To that:

var myTable = app.selection[0].texts[0].insertionPoints.item(-1).tables.add();

It will add a table at the last insertion point of your text selection.

(I did not include a check, if the selection is a valid text object)

Uwe

hamdifem
hamdifemAuthor
Inspiring
September 19, 2014

thank you very much

I have a problem

paragraph styles available but

I want to add

app.selection[0].texts[0].appliedParagraphStyle = NothingEnum.NOTHING;

2014-09-19 10:53 GMT+03:00 Laubender <forums_noreply@adobe.com>:

Can you help me about this script created by Laubender

<https://forums.adobe.com/people/Laubender> in InDesign Scripting - View

the full discussion <https://forums.adobe.com/message/6743798#6743798>