🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #14503

Re: How to set textcolumns using VB?

#14503
From: Olav_Kvern
Date: Fri, 30 Jan 2004 22:25
69 lines
4110 bytes
Serguei--

That's OK--you don't need the TextFramePreferences object to be read/write to change its properties. What read-only means, in this case, is that you can't directly set the TextFramePreferences object of one text frame to the TextFramePreferences object of another frame.

Here's an example of creating a text frame with multiple columns:



Rem Multi-column TextFrame Example 
Set myInDesign = CreateObject("InDesign.Application.CS") 
Rem Create a new document 
Set myDocument = myInDesign.Documents.Add 
Rem Set the measurement units to points 
myDocument.ViewPreferences.HorizontalMeasurementUnits = idMeasurementUnits.idPoints 
myDocument.ViewPreferences.VerticalMeasurementUnits = idMeasurementUnits.idPoints 
Rem Create a text frame on the first page 
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add 
Rem Size the frame to the margins 
myX1 = myDocument.Pages.Item(1).MarginPreferences.Left 
myX2 = myDocument.DocumentPreferences.PageWidth - myDocument.Pages.Item(1).MarginPreferences.Right 
myY1 = myDocument.Pages.Item(1).MarginPreferences.Top 
myY2 = myDocument.DocumentPreferences.PageWidth - myDocument.Pages.Item(1).MarginPreferences.Bottom 
myTextFrame.GeometricBounds = Array(myY1, myX1, myY2, myX2) 
Rem Set the text column count and text column gutter. 
myNumberOfColumns = 6 
myColumnGutter = 12 
myLeading = 14 
myTextFrame.TextFramePreferences.TextColumnCount = myNumberOfColumns 
myTextFrame.TextFramePreferences.TextColumnGutter = myColumnGutter 
myTextFrameWidth = myTextFrame.GeometricBounds(3) - myTextFrame.GeometricBounds(1) 
myColumnWidth = (myTextFrameWidth - (myColumnGutter * (myNumberOfColumns - 1))) / myNumberOfColumns 
myFrameHeight = 72 
Rem Enter some text in the frame, leaving blank paragraphs for the inline frames. 
myTextFrame.Contents = "This is the first text paragraph." & vbCr & vbCr & "This is the second text paragraph." & vbCr & vbCr & "This is the third text paragraph." 
myTextFrame.Texts.Item(1).Leading = myLeading 
Rem Create a rectangle in the text as an inline frame. 
Set myParagraph = myTextFrame.Paragraphs.Item(2) 
Set myRectangle = myParagraph.Rectangles.Add 
Rem Resize the bounds of the frame to the width of the column. 
myBounds = myRectangle.GeometricBounds 
myX1 = myBounds(1) 
myY1 = myBounds(0) 
myX2 = myX1 + myColumnWidth 
myY2 = myY1 + myFrameHeight 
myRectangle.GeometricBounds = Array(myY1, myX1, myY2, myX2) 
myRectangle.ContentType = idContentType.idGraphicType 
myParagraph.Leading = myFrameHeight 
Rem The parent of the rectangle is the character containing the rectangle. 
myRectangle.Parent.BaselineShift = myFrameHeight - myLeading 
Rem Create another inline graphic frame. 
Set myParagraph = myTextFrame.Paragraphs.Item(4) 
Set myRectangle = myParagraph.Rectangles.Add 
Rem Resize the bounds of the frame to the width of the column. 
myBounds = myRectangle.GeometricBounds 
myX1 = myBounds(1) 
myY1 = myBounds(0) 
myX2 = myX1 + myColumnWidth 
myY2 = myY1 + myFrameHeight 
myRectangle.GeometricBounds = Array(myY1, myX1, myY2, myX2) 
myRectangle.ContentType = idContentType.idGraphicType 
myParagraph.Leading = myFrameHeight 
Rem The parent of the rectangle is the character containing the rectangle. 
myRectangle.Parent.BaselineShift = myFrameHeight - myLeading

Does that help? It's not very pretty, but it should demonstrate all of the basic steps you'll need to go through.

Thanks,

Ole
Technical Details
Message-ID: <2ccfac61.2@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2ccfac61.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,fb97ad88fdf1e486
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2004-01-30 14:37:56 PST
From: Olav_Kvern@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: How to set textcolumns using VB?
Message-ID: <2ccfac61.2@webx.la2eafNXanI>
Date: Fri, 30 Jan 2004 14:25:43 -0800
References: <2ccfac61.-1@webx.la2eafNXanI>
Lines: 81
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit