🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #18752

Re: Can't Find Place Images from Folder script

#18752
From: Olav Kvern
Date: Mon, 03 Mar 2003 19:21
84 lines
4398 bytes
Brian--

Here's a VBScript version. Note that you'll have to specify a number of things in the script. I'll post a VB version in a bit.



Dim myInDesign 
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 = 4 
myNumberOfColumns = 3 
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 = "c:\myFilesToPlace" 
idProportionally = 1668247152 
idCenterContent = 1667591779 
myFramesPerPage = myNumberOfRows * myNumberOfColumns 
Set myInDesign = CreateObject("InDesign.Application.1.5") 
Set myDocument = myInDesign.Documents.Add 
Set myDocumentPreferences = myDocument.DocumentPreferences 
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject") 
Rem Fill in the path to the folder containing the files you want to place. 
Rem If you're add a user interface to this script, you can use a DirListBox 
Rem to set the folder location. 
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 




Thanks,

Ole
Technical Details
Message-ID: <1de813df.1@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de813df.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,51e89ef7de193d91
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-03-03 11:38:41 PST
From: "Olav Kvern" <okvern@adobe.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!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: Can't Find Place Images from Folder script
Message-ID: <1de813df.1@WebX.la2eafNXanI>
Date: Mon, 3 Mar 2003 11:21:12 -0800
References: <1de813df.-1@WebX.la2eafNXanI>
Lines: 89
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit