Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

move table within a textframe?

Guest
Jul 24, 2015 Jul 24, 2015

Hii

Can anyone please tell me how can I move a table within a textframe?

Is it possible to do so using vb.net?

Please please help

Thanks

TOPICS
Scripting
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 24, 2015 Jul 24, 2015

Hi,

It supposes to go similar like moving text.

How to find text which handles a table? Take character covered by insertionPoints before and after table.

Example:

// that is javascript so for vbs use the logic rather

// assumed that cursor is placed within table's parentStory and it is a new destination.

// it takes 1st table found in the story

var

  mStory = app.selection[0].parentStory,

  start = mStory.tables[0].storyOffset,

  tableHandler = mStory.insertionPoints.itemByRange(start, mStory.insertionPoints.nextItem(start)).characters[0],

  target = app.selection[0].insertionPoints[0],

  targetBase = mStory.insertionPoints.itemByRange(target, mStory.insertionPoints.nextItem(target)).characters[0];

  tableHandler.move(LocationOptions.BEFORE, targetBase);

Jarek

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 24, 2015 Jul 24, 2015

Hi

Thanks for replying.

I will try your code through vb and let me how it works out?

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2015 Jul 25, 2015

That's uncharacteristically verbose, Jarek -- can be done with these three lines:

var story = app.selection[0].parentStory;

var table = story.characters[story.tables[0].storyOffset.index];

table.move (LocationOptions.BEFORE, app.selection[0]);

And for the heck of it, sacrificing readability for brevity, in one line:

app.selection[0].parentStory.characters[app.selection[0].parentStory.tables[0].storyOffset.index].move(LocationOptions.BEFORE, app.selection[0]);

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 25, 2015 Jul 25, 2015

Thanks for this remark, Peter.

Can't remember when I persueded myself that move parameter suppose to be the same kind of object (IP to IP; char to char and so on)

Jarek

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 26, 2015 Jul 26, 2015

Can't remember when I persueded myself that move parameter suppose to be the same kind of object (IP to IP; char to char and so on)

Kind of is, but as usual Javascript does type conversion and sometimes you get lucky and it actually works (in this case it converts Story to Story.insertionPoints[0]).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2015 Jul 26, 2015

Vamitul -- I don't quite see the type conversion Story > Story.insertionPoints[0]. But I take your point that it's better not to rely on JS's type conversion, maybe like this:

var story = app.selection[0].parentStory;

var table = story.characters[story.tables[0].storyOffset.index];

var target = story.characters[app.selection[0].index];

table.move (LocationOptions.BEFORE, target);

So that the item to be moved and the target are the same type, here, characters. Or am I missing the point entirely?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 03, 2023 Aug 03, 2023

The same code I am using but it shows the error in LocationOptions. can you plz mention the TypeName of table.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 04, 2023 Aug 04, 2023

Hi @Aysha27550661f9sm ,

to answer this, we need a bit more information.

Where do you want the table to?

 

Please attach a sample InDesign document, use the forum controls for this, where it is clear what table you want to move to what target.

 

Also show minimized code that is not working for you.

 

Thanks,
Uwe Laubender
( Adobe Community Expert )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 04, 2023 Aug 04, 2023

In this I want to place the table 1 to little bit hight. Because one row in the table flown to next page. 

Dim tf As InDesign.TextFrame
For iFrm As Integer = 1 To indesignDocument.TextFrames.Count
tf = indesignDocument.TextFrames(iFrm)
If tf.Tables.Count > 0 Then
For iTabCount = 1 To tf.Tables.Count
iTableBodyFrame = tf.Tables(iTabCount)

 

Dim mStory = indesignApplication.Selection(0).parentStory, start = mStory.tables(0).storyOffset, tableHandler = mStory.insertionPoints.itemByRange(start, mStory.insertionPoints.nextItem(start)).characters(0), target = indesignApplication.Selection(0).insertionPoints(0), targetBase = mStory.insertionPoints.itemByRange(target, mStory.insertionPoints.nextItem(target)).characters(0)
indesignApplication.Selection(0).Move(LocationOptions.BEFORE, targetBase)
Next

End If
Next

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2023 Aug 07, 2023
LATEST

Hi @Aysha27550661f9sm ,

instead moving the table I would try to gain one line of text and change the tracking of the last paragraph of the section before to a different value. Or, if that will not work expand the height of the text frame of that page a little bit.

 

But I would do that only as a last step when all the final edits are done in the document.

 

What I cannot see from your screenshot:

Does the table "live" in its own paragraph?

 

Thanks,
Uwe Laubender
( Adobe Community Expert )

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