Article View: adobe.scripting.indesign
Article #431[CS4][VB] Bug or new "great" feature ? :( ... and solution
From: Robert Tkaczyk
Date: Tue, 24 Mar 2009 13:40
Date: Tue, 24 Mar 2009 13:40
49 lines
2378 bytes
2378 bytes
hi
could anybody please tell my WHY this code:
set myindi=createobject("indesign.application")
set mydoc=myindi.activedocument
set mySel = myindi.selection.item(1)
for a=mySel.textstyleranges.item(1).paragraphs.count to 1 step -1
msgbox(mySel.textstyleranges.item(1).paragraphs.item(a).textstyleranges.item(1).contents)
next
return different results in CS2 and CS4 ?
myText is like this:
item1
item2
item3
all three lines have same formatting - applied same ParagraphStyle - no local formatting - so there is only ONE TextStyleRange
when I try to process each line (from back) - and I'm refering to TextStyleRange of each paragraph - in CS2 I get contents of TextStyleRange ONLY from specified paragraph
item3
item2
item1
but in CS4 - it will return contents from current paragraph to end of TextStyleRange - so after processing all paragraphs I have:
item3
item2(enter)item3
item1(enter)item2(enter)item3
so ... there is another problem - if TextStyleRange (as parent) should work like parent Paragraph of same text - then why this TextStyleRange don't return WHOLE contents of parent TextStyleRange (contents of all three paragraphs) - but return from current paragraph to the end of TextStyleRange ?
ok ... and here is solution (dicovered when editing this post before sending) ...
msgbox(myindi.selection.item(1).textstyleranges.item(1).paragraphs.item(a).textstyleranges.item(1).paragraphs.item(1).contents)
after refering to TextStyleRange of Paragraph - we need to refer again to first Paragraph of this TextStyleRange ...
thanks
robin
--
www.adobescripts.com
Technical Details
Message-ID:
<1E2D9FAE2FA39FD3BE5D5AE67AF19457@in.webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f939a,90ce6fa61e127071,start X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Robert Tkaczyk <indesignscripts@wp.pl> Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: [CS4][VB] Bug or new "great" feature ? :( ... and solution Message-ID: <1E2D9FAE2FA39FD3BE5D5AE67AF19457@in.webcrossing.la2eafNXanI> Date: Tue, 24 Mar 2009 06:40:49 -0700 Lines: 61 User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) X-Antivirus: avast! (VPS 090323-0, 2009-03-23), Outbound message X-Antivirus-Status: Clean MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit