Article View: adobe.scripting.indesign
Article #18382Re: Total Newbie with VB Needs Help
From: Olav Kvern
Date: Thu, 03 Apr 2003 17:33
Date: Thu, 03 Apr 2003 17:33
47 lines
3301 bytes
3301 bytes
Harv--
It's possible to get VB.NET to work, but I think you might be better off with VBA (as mentioned above, VBA is included in MS Office applications) or with VB5 Control Creation Edition (CCE). VB5 CCE is available for download from: <http://msdn.microsoft.com/vbasic/downloads/tools/cce/default.asp>
Once you've got that, you should be able to work through the basic tutorial in the Scripting Guide. It shows you how to make the essential connection from VB->InDesign.
We'll work on getting your VB.NET to work once you're up to speed with VB5.
iolaire's script is a good one, but will miss rectangles inside groups, on master pages, and inside other page items. This is because myDocument.Rectangles contains the top-level rectangles on the pages of the document. Instead of iterating through that collection, use the Document.AllPageItems collection, which contains all of the page items on the document pages, regardless of their "nesting" level.
Note, however, that AllPageItems does not include objects on master pages--for those, you'll have to search the MasterSpread.AllPageItems collection for each MasterSpread.
Until we can get you going with VB, here's a VBScript that does what you want to do:
Rem ChangeStrokes
Set myInDesign = CreateObject("InDesign.application.2.0")
If myInDesign.Documents.Count > 0 Then
Rem Get a reference to the active document.
Set myDocument = myInDesign.ActiveDocument
For Each object In myDocument.AllPageItems
If TypeName(object) = "Rectangle" Then
If object.StrokeWeight = 0.5 Then
object.StrokeWeight = 1
End If
End If
Next
For Each MasterSpread In myDocument.MasterSpreads
For Each object In MasterSpread.AllPageItems
If TypeName(object) = "Rectangle" Then
If object.StrokeWeight = 0.5 Then
object.StrokeWeight = 1
End If
End If
Next
Next
End If
Copy the script out of this message, then paste it into Notepad and save it with the file extension .vbs to the Scripts folder inside your InDesign folder (create the folder if it doesn't already exist). At this point, you can run the script from the Scripts palette inside InDesign. (If you don't see the Scripts palette, or if its title is "Script," rather than "Scripts", you need to update to InDesign 2.0.2. If you don't see a Scripts folder, create one.)
Thanks,
Ole
Technical Details
Message-ID:
<1de894ee.6@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!news.tele.dk!news.tele.dk!small.news.tele.dk!luth.se!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de894ee.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,9dc40f7b1f727876 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-04-03 09:38: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!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!news.tele.dk!news.tele.dk!small.news.tele.dk!luth.se!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Total Newbie with VB Needs Help Message-ID: <1de894ee.6@WebX.la2eafNXanI> Date: Thu, 3 Apr 2003 09:33:02 -0800 References: <1de894ee.-1@WebX.la2eafNXanI> Lines: 64 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit