Article View: adobe.scripting.indesign
Article #9242Re: [VB/JS] [CS2] Moving location of Table in textframe
From: Dave_Saunders
Date: Thu, 07 Sep 2006 11:13
Date: Thu, 07 Sep 2006 11:13
23 lines
2429 bytes
2429 bytes
Move the paragraph (assuming those \n characters are returns, if they're forced line breaks, work in lines rather than paragraphs) containing the table to the new location. Assuming you're starting with a reference to the table, and interpreting your request to mean that you want to move it down the story one paragraph, you need something like this. (I'd normally use fewer statements, but it's easier to follow with each step isolated like this.) This will do it: myTable = app.selection[0]; myChar = myTable.cells[0].texts[0].parentStory.characters[myTable.storyOffset-1]; myPara = myChar.paragraphs[0]; myTarget = myPara.insertionPoints[-1].paragraphs[0].insertionPoints[-1]; myPara.move(LocationOptions.after, myTarget); I assume here that the table is selected, but you can get your reference to myTable any way you like. I was surprised to discover that tables don't have a parentStory property while the property is the text frame (ah, so I could have get at the story by: myTable.parent.parentStory For some reason, the storyOffset for a table is one larger than it should be. I'm using the "First shall be last" principle to get a reference for the insertion point at the start of the paragraph after next. The last insertion point of a paragraph is the same as the first of the next and when you ask for its paragraphs[0] property you always get the next, so do it twice as I do here and you're at the start of the paragraph after next. Something to watch out for: tables are always on a line by themselves, so if the character after the table is not a return, just move myChar instead of myPara. But this will also affect locating the target because there's one fewer paragraph in this case. Dave
Technical Details
Message-ID:
<3bc18d0b.0@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!news.glorb.com!newsfeed0.kamp.net!newsfeed.kamp.net!news.buerger.net!open-news-network.org!news.isoc.lu!webcrossingReferences:
<3bc18d0b.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,a7a2974c5459db7 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!news.glorb.com!newsfeed0.kamp.net!newsfeed.kamp.net!news.buerger.net!open-news-network.org!news.isoc.lu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: [VB/JS] [CS2] Moving location of Table in textframe Message-ID: <3bc18d0b.0@webcrossing.la2eafNXanI> Date: Thu, 7 Sep 2006 04:13:33 -0700 References: <3bc18d0b.-1@webcrossing.la2eafNXanI> Lines: 43 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit