🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #9148

Re: Database to Indesign: Questions

#9148
From: Olav_Kvern
Date: Mon, 11 Sep 2006 19:36
45 lines
2713 bytes
Hi John--

What is it that you're missing in the documentation? Have you looked through the example scripts or the Scripting Guide at all? Both show how to apply a style to a paragraph object, create text frames on master spread, and so on.

Here's a simple example of applying a style to a paragraph in InDesign.



Rem ApplyStyle.vbs 
Rem An InDesign CS2 VBScript 
Rem 
Rem Shows two different ways to apply a paragraph style to a paragraph. 
Set myInDesign = CreateObject("InDesign.Application.CS2") 
Set myDocument = myInDesign.Documents.Add 
Rem Create a paragraph style. 
Set myParagraphStyle = myDocument.ParagraphStyles.Add 
myParagraphStyle.Name = "NewParagraphStyle" 
Rem Change the character color and the point size of the paragraph style. 
myParagraphStyle.FillColor = myDocument.Swatches.Item(-1) 
myParagraphStyle.PointSize = 24 
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add 
myTextFrame.GeometricBounds = myGetBounds(myDocument, myDocument.Pages.Item(1)) 
myTextFrame.Contents = "This is some example text." & vbCr 
myTextFrame.InsertionPoints.Item(-1).Contents = "This is yet another example paragraph." & vbCr 
myTextFrame.InsertionPoints.Item(-1).Contents = "This is the last example paragraph." 
Set myParagraph = myTextFrame.Paragraphs.Item(1) 
Rem Applying a style using the ApplyStyle method 
myParagraph.ApplyStyle myParagraphStyle, True 
Rem Applying a style using the AppliedParagraphStyle property 
myTextFrame.Paragraphs.Item(-1).AppliedParagraphStyle = myParagraphStyle 
Function myGetBounds(myDocument, myPage) 
    myPageHeight = myDocument.DocumentPreferences.PageHeight 
    myPageWidth = myDocument.DocumentPreferences.PageWidth 
    myTop = myPage.MarginPreferences.Top 
    myLeft = myPage.MarginPreferences.Left 
    myRight = myPage.MarginPreferences.Right 
    myBottom = myPage.MarginPreferences.Bottom 
    myRight = myPageWidth - myRight 
    myBottom = myPageHeight - myBottom 
    myGetBounds = Array(myTop, myLeft, myBottom, myRight) 
End Function

Thanks,

Ole
Technical Details
Message-ID: <3bc18451.5@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!news.germany.com!news.isoc.lu!webcrossing
References: <3bc18451.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,fc46c622873f0e2e
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!news3.google.com!news4.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!news.germany.com!news.isoc.lu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: Database to Indesign:  Questions
Message-ID: <3bc18451.5@webcrossing.la2eafNXanI>
Date: Mon, 11 Sep 2006 12:36:00 -0700
References: <3bc18451.-1@webcrossing.la2eafNXanI>
Lines: 50
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit