🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15353

Re: [VB] Copy a table and paste it in a new page

#15353
From: Olav_Kvern
Date: Tue, 09 Dec 2003 00:34
37 lines
2421 bytes
Raymond--

As long as you're staying inside the document, you can use the move method to move the text. Consider the following example JavaScript (most of it is just setting up the example table and target text frame):



//MoveTableExample.js 
// 
//----------example document setup---------- 
var myDocument = app.documents.add(); 
var myBounds = new Array; 
var myString = "1a\t1b\t1c\r2a\t2b\t2c\r3a\t3b\t3c\r4a\t4b\t4c" 
var myBounds = myGetBounds(myDocument.pages.item(0), myDocument); 
var myTextFrame = myDocument.pages.item(0).textFrames.add(undefined, undefined, undefined, {geometricBounds:myBounds, contents:myString}) 
var myTable = myTextFrame.texts.item(0).convertToTable(); 
//Add a bit more text--InDesign will crash if we attempt to move *all* of the text in a story. 
myTextFrame.insertionPoints.item(-1).contents = "\rA bit more text.\r" 
var myParagraph = myTextFrame.paragraphs.item(0); 
//Create the destination text frame. 
var myDestinationPage = myDocument.pages.add(); 
var myBounds = myGetBounds(myDestinationPage, myDocument); 
var myDestinationTextFrame = myDestinationPage.textFrames.add(undefined, undefined, undefined, {geometricBounds:myBounds}); 
//Now move the table into the new text frame. 
myParagraph.move(LocationOptions.atBeginning, myDestinationTextFrame.parentStory); 
function myGetBounds(myPage, myDocument){ 
	myBounds[0] = myPage.marginPreferences.top; 
	myBounds[1] = myPage.marginPreferences.left; 
	myBounds[2] = myDocument.documentPreferences.pageHeight - myPage.marginPreferences.bottom; 
	myBounds[3] = myDocument.documentPreferences.pageWidth - myPage.marginPreferences.right; 
	return myBounds; 
}

Sorry, I guess that's a JavaScript. Hang on and I'll make a VBScript version.

Thanks,

Ole
Technical Details
Message-ID: <2cced027.3@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2cced027.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,50c714be408c8cfb
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-12-08 16:37:55 PST
From: Olav_Kvern@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: [VB] Copy a table and paste it in a new page
Message-ID: <2cced027.3@webx.la2eafNXanI>
Date: Mon, 8 Dec 2003 16:34:26 -0800
References: <2cced027.-1@webx.la2eafNXanI>
Lines: 43
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit