Skip to main content
Known Participant
October 7, 2010
Question

Script for Margin TexFrame

  • October 7, 2010
  • 1 reply
  • 1841 views

Is there a way to create a script to increase/decrease left margin and right margin in texframe?

Example:

If I select my textframe (Leftt: 0mm, Right: 0mm) with Tool Selection, and apply the script by shortcut to increase or decrease the margins 1mm to 1mm.

I use milimeters here in Brazil.

Thanks!!

This topic has been closed for replies.

1 reply

Jongware
Community Expert
Community Expert
October 7, 2010

Text frames do not actually have 'margins', the text frame border itself is "the margin".

Do you mean to:

1. Increase/decrease the text frame width? (If so: equal on both sides? From one side?)

2. Increase/decrease Text Inset? (Which changes the boundaries of the text inside but leaves the frame size the same)

3. Increase/decrease the active page margins -- the purple guidelines? (Which will do nothing, actually, for any text frames on that page unless "Layout Adjustment" is enabled. Even then, I'm not sure if changing the margins using a script will make "Layout adjust" do its thing.)

Foxy_FordAuthor
Known Participant
October 7, 2010

Hmm, sorry. Maybe I couldnt explain.

I mean Increase/Decrease equalon both sides: Right Indent and Left Indent:

Inspiring
October 8, 2010

HI Foxy,

Try it.

var confResult = false; myDisplayDialog() if(confResult == true) { if(app.selection[0].constructor.name == "TextFrame") { app.selection[0].paragraphs.everyItem().leftIndent = app.selection[0].paragraphs[0].leftIndent+1; app.selection[0].paragraphs.everyItem().rightIndent = app.selection[0].paragraphs[0].rightIndent+1; } } else { if(app.selection[0].constructor.name == "TextFrame") { app.selection[0].paragraphs.everyItem().leftIndent = app.selection[0].paragraphs[0].leftIndent-1; app.selection[0].paragraphs.everyItem().rightIndent = app.selection[0].paragraphs[0].rightIndent-1; } } function myDisplayDialog() { var myDialog= new Window ('dialog', 'Change Indent'); var buttonInc = myDialog.add('button', undefined, 'Increase'); var buttonDec = myDialog.add('button', undefined, 'Decrease'); buttonInc.onClick = function () {      confResult = true;      myDialog.close(); } buttonDec.onClick = function () {      confResult = false;      myDialog.close(); } myDialog.show(); }

Shonky