🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16086

Re: Placing 1 image per document page

#16086
From: Olav_Kvern
Date: Wed, 15 Oct 2003 04:41
87 lines
4599 bytes
Sharon--

I don't know if this one looks like an alien langauge or not--but here's my old "PlaceAllFiles.vbs" script, modified to place one file per page.



Rem PlaceAllFiles.vbs 
Rem An InDesign 2.0 Script 
Rem Enter the number or rows and columns you want. If you're adding 
Rem a user interface to this script, you can get these values from 
Rem a pair of text fields. 
myNumberOfRows = 1 
myNumberOfColumns = 1 
Rem If you want to remove any empty frames, set myRemoveEmptyFrames to true. 
myRemoveEmptyFrames = True 
Rem Enter the path to the folder containing the images you want to place. 
myFolderName = "g:\images" 
Rem If you are running this script from InDesign's Scripts palette, 
Rem remove the "Rem" from the start of the next two lines. 
Rem idProportionally = 1668247152 
Rem idCenterContent = 1667591779 
Rem 
myFramesPerPage = myNumberOfRows * myNumberOfColumns 
Set myInDesign = CreateObject("InDesign.Application.2.0") 
Set myDocument = myInDesign.Documents.Add 
Set myDocumentPreferences = myDocument.DocumentPreferences 
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject") 
Set myFolder = myFileSystemObject.GetFolder(myFolderName) 
myNumberOfFrames = myFolder.Files.Count 
myNumberOfPages = Round(myNumberOfFrames / myFramesPerPage) 
If (myNumberOfPages * myFramesPerPage) < myNumberOfFrames Then myNumberOfPages = myNumberOfPages + 1 
myDocumentPreferences.NumberOfPages = myNumberOfPages 
myDocumentPreferences.PagesPerSpread = 1 
Set myPage = myDocument.Pages.Item(1) 
Set myMarginPreferences = myPage.MarginPreferences 
myLeftMargin = myMarginPreferences.MarginLeft 
myTopMargin = myMarginPreferences.MarginTop 
myRightMargin = myMarginPreferences.MarginRight 
myBottomMargin = myMarginPreferences.MarginBottom 
myLiveWidth = myDocumentPreferences.PageWidth - (myLeftMargin + myRightMargin) 
myLiveHeight = myDocumentPreferences.PageHeight - (myTopMargin + myBottomMargin) 
myFrameWidth = myLiveWidth / myNumberOfColumns 
myFrameHeight = myLiveHeight / myNumberOfRows 
Set myPages = myDocument.Pages 
Rem Construct the frames in reverse order. Don't laugh--this will 
Rem save us time later (when we place the graphics). 
For myCounter = myDocument.Pages.Count To 1 Step -1 
    Set myPage = myPages.Item(CInt(myCounter)) 
    For myRowCounter = myNumberOfRows To 1 Step -1 
        myY1 = myTopMargin + (myFrameHeight * (myRowCounter - 1)) 
        myY2 = myTopMargin + (myFrameHeight * myRowCounter) 
        For myColumnCounter = myNumberOfColumns To 1 Step -1 
            myX1 = myLeftMargin + (myFrameWidth * (myColumnCounter - 1)) 
            myX2 = myLeftMargin + (myFrameWidth * myColumnCounter) 
            Set myRectangle = myPage.Rectangles.Add 
            myRectangle.GeometricBounds = Array(myY1, myX1, myY2, myX2) 
        Next  
    Next  
Next  
Rem Because we constructed the frames in reverse order, rectangle 1 
Rem is the first rectangle on page 1, so we can simply iterate through 
Rem the rectangles, placing a file in each one in turn. 
myCounter = 1 
Set myFiles = myFolder.Files 
For Each File In myFiles 
	myPath = File.Path 
	myDocument.PageItems.Item(myCounter).Place myPath 
	myDocument.PageItems.Item(myCounter).Fit (idProportionally) 
	myDocument.PageItems.Item(myCounter).Fit (idCenterContent) 
	myCounter = myCounter + 1 
Next  
If myRemoveEmptyFrames = True Then 
    For Each Rectangle In myDocument.Rectangles 
        If Rectangle.ContentType = idUnassigned Then 
            Rectangle.Delete 
        End If 
    Next  
End If 




Copy the script out of this message and into Notepad. Change the file path to the path to the folder containing the images you want to place. Save it with the file extension ".vbs" and put it in the Scripts folder inside your InDesign application folder. Run the script by double-clicking the script name in the Scripts palette.

Thanks,

Ole
Technical Details
Message-ID: <2ccddc8b.1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2ccddc8b.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,a513381a4562e8b5
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-10-14 22:07:33 PST
From: Olav_Kvern@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: Placing 1 image per document page
Message-ID: <2ccddc8b.1@webx.la2eafNXanI>
Date: Tue, 14 Oct 2003 21:41:11 -0700
References: <2ccddc8b.-1@webx.la2eafNXanI>
Lines: 95
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit