🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #9748

Re: [VB] How to apply ParaStyle to range of cells in table ?

#9748
From: Olav_Kvern
Date: Fri, 21 Jul 2006 20:55
30 lines
2010 bytes
Hi Robin--

Why not use a JavaScript snippet in your VBScript? Something like this:



Rem Assumes that the active document contains at least one story, 
Rem that that story includes a table with more than three rows, 
Rem and that the document contains a paragraph style named 
Rem "myParagraphStyle". 
Set myInDesign = CreateObject("InDesign.Application.CS2") 
Set myDocument = myInDesign.Documents.Item(1) 
Set myStory = myDocument.Stories.Item(1) 
Set myTable = myStory.Tables.Item(1) 
myStyleName = "myParagraphStyle" 
myRowIndex = 2 
Rem Create JavaScript string; 
myJavaScript = "var myStory = app.documents.item(0).stories.itemByID(" & myStory.Id & ");" & vbCr 
myJavaScript = myJavaScript & "var myTable = myStory.tables.itemByID(" & myTable.Id & ");" & vbCr 
myJavaScript = myJavaScript & "var myRow = myTable.rows.item(" & myRowIndex & ");" & vbCr 
myJavaScript = myJavaScript & "var myStyle = app.documents.item(0).paragraphStyles.item(""" & myStyleName & """);" & vbCr 
myJavaScript = myJavaScript & "myRow.cells.everyItem().texts.item(0).applyStyle(myStyle, true);" & vbCr 
myInDesign.DoScript myJavaScript, idScriptLanguage.idJavascript 


You could, of course, use myInDesign.ScriptArgs to pass values to a JavaScript, but if you're writing the JavaScript inline in your VBScript, there's no need.

Thanks,

Ole
Technical Details
Message-ID: <3bc0f55a.4@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!newsfeed.freenet.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing
References: <3bc0f55a.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,a5d60b8eced08491
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Olav_Kvern@adobeforums.com
Newsgroups: adobe.scripting.indesign
Subject: Re: [VB] How to apply ParaStyle to range of cells in table ?
Message-ID: <3bc0f55a.4@webcrossing.la2eafNXanI>
Date: Fri, 21 Jul 2006 13:55:27 -0700
References: <3bc0f55a.-1@webcrossing.la2eafNXanI>
Lines: 34
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!newsfeed.freenet.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing