Article View: adobe.scripting.indesign
Article #19761Re: VB6&ID - Replace function like ImportXML
From: Olav Kvern
Date: Thu, 21 Nov 2002 06:50
Date: Thu, 21 Nov 2002 06:50
37 lines
2984 bytes
2984 bytes
David-- First, the deal with declaring what type a variable is (aka "Dim") is (or should be) a matter of personal preference. VB6 gives you the ability to work either way--when you turn "Option Explicit" on, you must declare all of your variables, with it off, you only need declare variables when you want to take advantage of VB's nifty auto-complete feature.<g> You can find several rants by me on this topic in the forum archives. I strongly prefer working with Option Explicit off--precisely for the reason you state. Having it on makes it much more difficult to process heterogenous collections of objects. The type mismatch error is not a shortcoming of InDesign scripting--it's just a VB implementation detail. In similar fashion, the problem of some converted frames (i.e., from QuarkXPress or PageMaker) not getting their content type set is a bug in the converter plug-in, and not a scripting bug (and, alas, far from the only converter bug<g>). If you're looking for text frames, why not use the TextFrames collection? If you're processing all page items, use a Select Case statement with the TypeName function, as in: Rem Given a reference to a Document "myDocument"... For myCounter = 1 to myDocument.AllPageItems.Count Select Case TypeName(myDocument.AllPageItems.Item(myCounter)) Case "TextFrame" Rem Do something with the text frame Case "Rectangle" Rem Do something with the rectangle Case "Oval" Rem Do something with the oval Rem Case ... you get the idea Case Else Rem Do the default thing End Select Next Also, if what you want to do is replace or update image links, why not iterate through the document's Links collection instead? The link type property will tell you if it's the sort of graphic you want, and you can update it right there. No need to look through all of the page items. As far as my opinion of ID2, I first have to say that I am an Adobe employee, and am the author (outside of my Adobe job) of a Peachpit Press book on InDesign. So I'm biased.<g> But I think ID2 rocks. I've been in the industry a long time, and thought that a page layout program couldn't excite me anymore--but I was wrong. Thanks, Ole
Technical Details
Message-ID:
<1de6b092.5@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de6b092.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,9fb81744ad733cf6 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-11-20 23:08:07 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: VB6&ID - Replace function like ImportXML Message-ID: <1de6b092.5@WebX.la2eafNXanI> Date: Wed, 20 Nov 2002 22:50:21 -0800 References: <1de6b092.-1@WebX.la2eafNXanI> Lines: 53 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit