Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Hi
Thanks for replying.
I will try your code through vb and let me how it works out?
Thanks
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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]).
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
The same code I am using but it shows the error in LocationOptions. can you plz mention the TypeName of table.
Copy link to clipboard
Copied
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 )
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 )
Find more inspiration, events, and resources on the new Adobe Community
Explore Now