🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #8861

Re: How to put a paragraph into a 1 by 1 table

#8861
From: Olav_Kvern
Date: Thu, 21 Sep 2006 19:49
39 lines
2092 bytes
Hi Ariel--

Try something like this:



Rem BoxParagraphs.vbs 
Rem An InDesign CS2 VBScript 
Rem 
Rem Converts all paragraphs of a given paragraph style 
Rem to single-cell tables. 
Set myInDesign = CreateObject("InDesign.Application.CS2") 
Set myDocument = myInDesign.Documents.Item(1) 
Set myStyle = myDocument.ParagraphStyles.Item("HRBox") 
myInDesign.FindPreferences = idNothingEnum.idNothing 
myInDesign.ChangePreferences = idNothingEnum.idNothing 
myInDesign.FindPreferences.AppliedParagraphStyle = myStyle 
Set myFoundItems = myDocument.Search() 
myInDesign.FindPreferences = idNothingEnum.idNothing 
If myFoundItems.Count <> 0 Then 
    For myCounter = myFoundItems.Count To 1 Step -1 
        Set myFoundItem = myFoundItems.Item(myCounter) 
        Set myStartCharacter = myFoundItem.Characters.Item(1) 
        Rem Special case for the last paragraph in a story. 
        Set myEndCharacter = myFoundItem.Characters.Item(-1) 
        If myEndCharacter.Contents = vbCr Then 
            Set myEndCharacter = myFoundItem.Characters.Item(-2) 
        End If 
        Rem Get the text of the paragraph, excluding the return character. 
        Set myText = myFoundItem.Texts.ItemByRange(myStartCharacter, myEndCharacter) 
        Rem Convert the paragraph to a table. 
        Set myTable = myText.Item(1).ConvertToTable 
        Rem Adjust table properties here, if necessary. 
    Next 
End If

Thanks,

Ole
Technical Details
Message-ID: <3bc1ba48.0@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!news.ecp.fr!news.germany.com!news.isoc.lu!webcrossing
References: <58B49DDE8CFB764A53E11E78EDD2D04C@in.webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,82604a7f44cea2dd
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Olav_Kvern@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!news.ecp.fr!news.germany.com!news.isoc.lu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: How to put a paragraph into a 1 by 1 table
Message-ID: <3bc1ba48.0@webcrossing.la2eafNXanI>
Date: Thu, 21 Sep 2006 12:49:11 -0700
References: <58B49DDE8CFB764A53E11E78EDD2D04C@in.webcrossing.la2eafNXanI>
Lines: 38
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit