🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #9620

Re: Generating a "Tables" Collection Array

#9620
From: Helix
Date: Wed, 16 Aug 2006 19:03
79 lines
3343 bytes
Well for those of you who were stymied by my request you may be happy
to know I have coded the problem with success.  I would like to hear
comments from interested parties who try this routine.  I have tested
it extensively and found no problems but you never know for sure.

Start Code Snippet >>
/*
InDesign Table Array Constructor

	The Process is to build an Array of tables in a document so that
working with the tables
	becomes a lot easier.  This method uses a recursion as a method of
building the index
	so don't be confused by the routine calling itself.  This is a way
of finding tables
	that are nested within tables.  If the tables are located in text
frames in table cells
	they are treated as additional stories and will also be added to the
table collection array.

Author: Helix
Company: Purifiner.com
Dated: August 16, 2006
Revision 3.0

*/
myTablesCollection = [""]
a = myTablesCollection.shift()
replaceSelection = SelectionOptions.replaceWith
//  *** DOCUMENT open?
if(app.documents.length != 0){
//	*** DOCUMENT content? >>
 		if (app.activeDocument.allPageItems.length != 0){

// 	*** STORIES loop >>
 			for(myStories = 0; myStories < app.activeDocument.stories.length;
myStories ++){
 				myStory=app.activeDocument.stories.item(myStories)

//  *** TABLES loop start
 				for(var myTables = 0; myTables < myStory.tables.length; myTables
++){
 					var myTable = myStory.tables.item(myTables);
 					myTable.select(replaceSelection)
 //						alert ("Found This Table in Story:" + myStories)
 					myTablesCollection.push(myTable)
 						searchForTables(myTable)  //  Jump to Recursive Routine
				}
// << TABLES loop
			}
// << Stories loop


		}
// << DOCUMENT content

		else {
				alert ("Got Nothin");
		}
//
}
//  << DOCUMENT open?
else {
alert ("Nothin Open");
}
//  Step through table array
for(var myTables = 0;myTables < myTablesCollection.length; myTables++){
	myTablesCollection[myTables].select(replaceSelection)
	alert ("Table:" + myTables)
	}


 // ------------------------------------------------

<<  End Code Snippet

Thanks for your help if you decide to participate.

Helix
Technical Details
Message-ID: <1155755024.702540.296710@m79g2000cwm.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!m79g2000cwm.googlegroups.com!not-for-mail
References: <1155314042.087206.116000@i3g2000cwc.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,cf398d42ebe5c0b0
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!m79g2000cwm.googlegroups.com!not-for-mail
From: "Helix" <Hangtimer@gmail.com>
Newsgroups: adobe.scripting.indesign
Subject: Re: Generating a "Tables" Collection Array
Date: 16 Aug 2006 12:03:44 -0700
Organization: http://groups.google.com
Lines: 80
Message-ID: <1155755024.702540.296710@m79g2000cwm.googlegroups.com>
References: <1155314042.087206.116000@i3g2000cwc.googlegroups.com>
NNTP-Posting-Host: 69.192.204.151
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1155755030 24256 127.0.0.1 (16 Aug 2006 19:03:50 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 16 Aug 2006 19:03:50 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: m79g2000cwm.googlegroups.com; posting-host=69.192.204.151;
   posting-account=P0cxeQ0AAAAFR2LWwJzh6CVRk5LvuOvb