🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #19749

Re: How do I select all?

#19749
From: Olav Kvern
Date: Wed, 20 Nov 2002 20:08
118 lines
5256 bytes
Vincent-- 

Ah, I see. Here's one that does what you want--it doesn't open a new document, it rearranges things in the existing one (so make sure have saved the original before running the script). Sorry to hear about your "m" key. 



Rem Business card layout 
Dim myInDesign 
Dim myArray() 
Rem if you plan to run this from the Scripts palette, comment 
rem out the following line. 
'idMSInches = 2053729891 
Set myInDesign = CreateObject("InDesign.Application.2.0") 
Set myDocument = myInDesign.ActiveDocument 
Rem Set the measurement units to inches 
myDocument.ViewPreferences.HorzMeasurementUnits = idMSInches 
myDocument.ViewPreferences.VertMeasurementUnits = idMSInches 
Rem Reset the zero point 
myDocument.ZeroPoint = Array(0, 0) 
Rem get a reference to page 1 
Set myPage = myDocument.Pages.Item(1) 
Rem Write the GeometricBounds for all objects into the label property of the objects. 
Rem We'll use this later to get the objects back into their proper position, as they may 
Rem move when we resize the page. 
For myCounter = 1 To myPage.PageItems.Count 
    Set myPageItem = myPage.PageItems.Item(myCounter) 
    myGeometricbounds = myPageItem.GeometricBounds 
    myX1 = CStr(myGeometricbounds(1)) 
    myY1 = CStr(myGeometricbounds(0)) 
    myX2 = CStr(myGeometricbounds(3)) 
    myY2 = CStr(myGeometricbounds(2)) 
    myPageItem.Label = myY1 & "," & myX1 & "," & myY2 & "," & myX2 
Next 
Rem Set the page size 
myDocument.DocumentPreferences.PageWidth = 7.5 
myDocument.DocumentPreferences.PageHeight = 8.5 
Rem Set the page margins to .25 inches 
myPage.MarginPreferences.MarginTop = 0.25 
myPage.MarginPreferences.MarginLeft = 0.25 
myPage.MarginPreferences.MarginBottom = 0.25 
myPage.MarginPreferences.MarginRight = 0.25 
Rem reset the zero point 
myDocument.ZeroPoint = Array(0.25, 0.25) 
Rem in VBScript, we can't use a collection, so we'll use an array. 
Rem (Arrays are zero based, so the size of the array should be 1 shy of Page.PageItems.Count) 
ReDim myArray(myPage.PageItems.Count - 1) 
Rem Now move the page items back to their proper locations. 
For myCounter = 1 To myPage.PageItems.Count 
    Set myPageItem = myPage.PageItems.Item(myCounter) 
    myTemp = Split(myPageItem.Label, ",") 
    myX1 = CDbl(myTemp(1)) 
    myY1 = CDbl(myTemp(0)) 
    myX2 = CDbl(myTemp(3)) 
    myY2 = CDbl(myTemp(2)) 
    myPageItem.GeometricBounds = Array(myY1, myX1, myY2, myX2) 
    Set myArray(myCounter - 1) = myPageItem 
Next 
For myCounter = 0 To UBound(myArray) 
    Set myPageItem = myArray(myCounter) 
    myDuplicatePageItem myPageItem, Array(0, 2) 
    myDuplicatePageItem myPageItem, Array(0, 4) 
    myDuplicatePageItem myPageItem, Array(0, 6) 
    myDuplicatePageItem myPageItem, Array(3.5, 0) 
    myDuplicatePageItem myPageItem, Array(3.5, 2) 
    myDuplicatePageItem myPageItem, Array(3.5, 4) 
    myDuplicatePageItem myPageItem, Array(3.5, 6) 
Next 
Rem reset the zero point 
myDocument.ZeroPoint = Array(0, 0) 
Rem set up the cut marks on the sides 
For myMarkCounter = 1 To 2 
    If myMarkCounter = 1 Then 
        myLeftEdge = 0 
        myRightEdge = 0.125 
    Else 
        myLeftEdge = 7.325 
        myRightEdge = 7.5 
    End If 
    For myCounter = 1 To 5 
        myY = 0.25 + ((myCounter - 1) * 2) 
        Set myLine = myPage.Lines.Add 
        myLine.StrokeWeight = 0.25 
        myLine.StrokeColor = myDocument.Swatches.Item("Registration") 
        Set myPath = myLine.Paths.Item(1) 
        myPath.EntirePath = Array(Array(myLeftEdge, myY), Array(myRightEdge, myY)) 
    Next 
Next 
Rem Set up the cut marks on the top and bottom 
For myMarkCounter = 1 To 2 
    If myMarkCounter = 1 Then 
        myY1 = 0 
        myY2 = 0.125 
    Else 
        myY1 = 8.325 
        myY2 = 8.5 
    End If 
    For myCounter = 1 To 3 
        myX = 0.25 + ((myCounter - 1) * 3.5) 
        Set myLine = myPage.Lines.Add 
        myLine.StrokeWeight = 0.25 
        myLine.StrokeColor = myDocument.Swatches.Item("Registration") 
        Set myPath = myLine.Paths.Item(1) 
        myPath.EntirePath = Array(Array(myX, myY1), Array(myX, myY2)) 
    Next 
Next 
Function myDuplicatePageItem(myPageItem, myMoveDistance) 
    Set myNewPageItem = myPageItem.Duplicate 
    myNewPageItem.Move , myMoveDistance 
End Function 




I'm hoping these examples are starting to make sense to you...? 

Thanks, 

Ole
Technical Details
Message-ID: <1de6ae99.2@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!proxad.net!proxad.net!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de6ae99.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,2c531b5dde9d3835
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-11-20 12:38:05 PST
From: "Olav Kvern" <okvern@adobe.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!proxad.net!proxad.net!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: How do I select all?
Message-ID: <1de6ae99.2@WebX.la2eafNXanI>
Date: Wed, 20 Nov 2002 12:08:17 -0800
References: <1de6ae99.-1@WebX.la2eafNXanI>
Lines: 121
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit