🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #9279

Re: Styling tables with table styles and cell styles

#9279
From: Martin Fischer*
Date: Thu, 24 Aug 2006 18:37
52 lines
2087 bytes
Meanwhile I have got an answer from Teacup Support Team.

CellStyles cannot be referred by index. They need to be referred to by name. Here is an example:

 
// removeTCStyles.jsx

if(app.documents.length > 0){ 
	var myDocument; 
	with (myDocument = app.activeDocument){ 
		cellStyles.everyItem().remove();  
		var styleNames = new Array(); 
		var count = 0; 
		var currentStyle = cellStyles.firstItem(); 
		while (currentStyle != null) { 
			styleNames[count] = currentStyle.name; 
			currentStyle = cellStyles.nextItem(currentStyle); 
			count++; 
		} 
		for (x in styleNames) { 
			myDocument.cellStyles.item(styleNames[x]).remove(); 
		} 
	} 
} 
else{ 
	alert("No documents are open. Please open a document and try again."); 
} 




To import Table- and CellStyles it is necessary to set the ReplaceOption to "ReplaceOption.overwrite" or "RaplaceOption.rename".

Here is an example for import of Styles:

 
// importTCStyles.jsx

var myDoc = app.documents[0]; 
var myFile = File.openDialog("Master of Table- and CellStyles");  
//myDoc.importTableStyles(myFile, ReplaceOption.overwrite); // imports TableStyles 
myDoc.importCellStyles(myFile, ReplaceOption.overwrite); // imports CellStyles 




But you have to take care that you don't import TableStyles and CellStyles at once: This will crash InDesign.
Importing only the TableStyles and importing CellStyles later works.

Nothing is perfect. ;-)

Martin
Technical Details
Message-ID: <3bc16072.2@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossing
References: <3bc16072.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,5d475286f78b342a
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Martin Fischer*" <martin.fischer@online.de>
Newsgroups: adobe.scripting.indesign
Subject: Re: Styling tables with table styles and cell styles
Message-ID: <3bc16072.2@webcrossing.la2eafNXanI>
Date: Thu, 24 Aug 2006 11:37:09 -0700
References: <3bc16072.-1@webcrossing.la2eafNXanI>
Lines: 51
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossing