Article View: adobe.scripting.indesign
Article #16511Applying paragraph styles
From: B Holt
Date: Fri, 29 Aug 2003 18:12
Date: Fri, 29 Aug 2003 18:12
78 lines
3409 bytes
3409 bytes
I'm bringing in a series of strings into a story that spans over several text frames and across several pages.
I have a record that stores the text strings as they are pulled out of an external file.
Private Type AdRecord
adtext As String
adprice As String
adphone As String
End Type
each of the fields is used in combination with the others to form one "ad".
The ads are supposed to look like this:
texthere(left justified)
pricehere(right justified)
phonehere(left justified, followed by a paragraph rule below it.)
I can bring in the text ok:
The strings are placed at the top of the first text frame (in reverse order, so that the first ad at the top at the end)
but i am running into trouble when i try and apply paragraph formatting to the text. the paragraph styles don't 'stay with' the paragraph as it's pushed down the story.
here is my code:
-----------------------------
Set ParaNorm = myDocument.ParaStyles.Add
ParaNorm.PointSize = CDbl(Text5.Text)
ParaNorm.AppliedFont = Text4.Text
ParaNorm.Justification = idLeftJustified
ParaNorm.KerningMethod = "None"
ParaNorm.Tracking = -12
ParaNorm.Leading = 9.5
ParaNorm.SpaceAfter = "0p9"
ParaNorm.KeepAllLinesTogether = True
ParaNorm.Name = "Normal"
Set ParaUL = myDocument.ParaStyles.Add
ParaUL.PointSize = CDbl(Text5.Text)
ParaUL.AppliedFont = Text4.Text
ParaUL.Justification = idLeftJustified
ParaUL.KerningMethod = "None"
ParaUL.Tracking = -12
ParaUL.Leading = 9.5
ParaUL.RuleBelow = True
ParaUL.RuleBelowOffset = "0p7"
ParaUL.RuleBelowLineWeight = 0.25
ParaUL.SpaceAfter = "0p9"
ParaUL.KeepAllLinesTogether = True
ParaUL.Name = "Underline"
Set myStory = TFrameArray(1).ParentStory
myStory.KeepAllLinesTogether = True
For i = UBound(SectionArray) - 2 To 0 Step -1
myStory.TextContents = Replace(SectionArray(i).adphone, "<R>", vbCr) & vbCr & myStory.TextContents
Set myParagraph = myStory.Paragraphs.Item(1)
myParagraph.ParagraphStyle = myDocument.ParaStyles.Item("Underline")
myStory.TextContents = SectionArray(i).adtext & vbCr & SectionArray(i).adprice & vbCr & myStory.TextContents
Set myParagraph = myStory.Paragraphs.Item(1)
myParagraph.ParagraphStyle = myDocument.ParaStyles.Item("Normal")
Next
-----------------------------
What i end up with is the entire story being formatted using the 'underline' paragraph style, except for the first paragraph, which has the 'normal' style applied to it.
I understand why my code isn't working as intended, but I don't know enough about indesign to figure out how to get it to work like i want.
any help is appriciated.
Technical Details
Message-ID:
<2ccd2832.-1@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!webxShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,c6b12720234435b5,start X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-08-29 11:37:52 PST From: "B Holt" <holtwj@mcmaster.ca> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Applying paragraph styles Message-ID: <2ccd2832.-1@webx.la2eafNXanI> Date: Fri, 29 Aug 2003 11:12:39 -0700 Lines: 89 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit