🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #19877

Re: Database Driven Catalog - ???

#19877
From: maxdunn
Date: Tue, 19 Nov 2002 22:06
111 lines
5859 bytes
MAINLY, you use both "oPage" and "myPage": use one, so the current reference is to the current page... 

A few other things: 
1. you really don't need do while loops inside the main do while loop. Keep loops to a minimum and you'll see things more clearly. 
2. I can't think in terms of column 0 and row 0, I would start with 1 (just a preference, but may help un-confuse things). 
3. If you're going to reference the InDesign application in both functions, might as well declare it outside both functions. 

I hacked around with your code and got the following to work (of course tweak the dimensions - I don't think the row height should have any relation to the gutter, in fact you can set the dimensions without relating to the margin dimensions if you like). this at least adds a page properly. 

Dim myInDesign As InDesign.Application 
Public Function SetupPage(myPage, iPageCounter) 
Set myDocument = myInDesign.ActiveDocument 
Set myPage = myPage 
myPage.AppliedMaster = myDocument.MasterSpreads.Item(1) 
myPageWidth = myDocument.DocumentPreferences.PageWidth 
myPageHeight = myDocument.DocumentPreferences.PageHeight 
myInDesign.ActiveDocument.ViewPreferences.HorzMeasurementUnits = idMSPicas 
myInDesign.ActiveDocument.ViewPreferences.VertMeasurementUnits = idMSPicas 
MyMarginLeft = myPage.MarginPreferences.MarginLeft 
myMarginTop = myPage.MarginPreferences.MarginTop 
myMarginRight = myPage.MarginPreferences.MarginRight 
myMarginBottom = myPage.MarginPreferences.MarginBottom 
myGutter = myPage.MarginPreferences.ColumnGutter 
mycolumns = 4 
myRows = 4 
myCW = (((myPageWidth - (MyMarginLeft + myMarginRight)) - (myGutter * (mycolumns - 1))) / mycolumns) 
myRH = ((myPageHeight - (myMarginTop + myMarginBottom + (myGutter * (mycolumns - 1)))) / myRows) 
myColumnCounter = 0 
myRowCounter = 1 
For i = 1 To 16 
    myColumnCounter = myColumnCounter + 1 
    If myRowCounter = 5 Then 
        myRowCounter = 1 
    End If 
    If myColumnCounter = 5 Then 
        myRowCounter = myRowCounter + 1 
        myColumnCounter = 1 
    End If 
    myTop = ((myRowCounter - 1) * myRH) + myMarginTop + myGutter 
    myBottom = myTop + myRH 
    myLeft = ((myColumnCounter - 1) * myCW) + (myGutter * (myColumnCounter - 1)) + MyMarginLeft 
    myRight = myLeft + myGutter + myCW 
    Set myTextFrame = myPage.TextFrames.Add 
    myTextFrame.GeometricBounds = Array(myTop, myLeft, myTop + (myRH / 4), myRight) 
    myTextFrame.Label = "Name-" & iPageCounter & "-" & myColumnCounter & "-" & myRowCounter 
    Set myTextFrame2 = myPage.TextFrames.Add 
    myTextFrame2.GeometricBounds = Array(myBottom - (myRH / 8), myRight, myBottom, myLeft) 
    myTextFrame2.Label = "Info-" & iPageCounter & "-" & myColumnCounter & "-" & myRowCounter 
    Set myRectangle1 = myPage.Rectangles.Add 
    myRectangle1.GeometricBounds = Array(myTop + (myRH / 4), myLeft, myBottom - (myRH / 8), myRight) 
    myRectangle1.Label = "Photo-" & iPageCounter & "-" & myColumnCounter & "-" & myRowCounter 

Next 
End Function 

Public Function DBtoID() 
Dim db As DAO.Database 
Dim rs As DAO.Recordset 
Set db = CurrentDb 
Set rs = db.OpenRecordset("Madison Items", dbOpenDynaset) 
Set myInDesign = CreateObject("InDesign.Application.2.0") 
Set myDocument = myInDesign.ActiveDocument 
myInDesign.Activate 
Set myPage = myDocument.Pages.Item(1) 
myColumnCounter = 0 
myRowCounter = 1 

iPageCounter = 1 
SetupPage myPage, iPageCounter 

Do While Not rs.EOF 
    myColumnCounter = myColumnCounter + 1 
    If myRowCounter = 5 Then 
        myRowCounter = 1 
    End If 
    If myColumnCounter = 5 Then 
        If myRowCounter = 4 Then 
            Set myPage = myDocument.Pages.Add 
            iPageCounter = iPageCounter + 1 
            SetupPage myPage, iPageCounter 
            myColumnCounter = 0 
            myRowCounter = 0 
        End If 
        myRowCounter = myRowCounter + 1 
        myColumnCounter = 1 
    End If 
    sBuf1 = rs!Pre 
    sBuf2 = rs!Description 
    sBuf3 = rs!Sub 
    iFrame = "Name-" & iPageCounter & "-" & myColumnCounter & "-" & myRowCounter 
    Set iTextFrame = myPage.TextFrames.Item(iFrame) 
    iTextFrame.InsertionPoints.Item(-1).TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3 
    sBuf4 = rs!Number 
    sBuf5 = rs!Pak 
    iFrame2 = "Info-" & iPageCounter & "-" & myColumnCounter & "-" & myRowCounter 
    Set iTextFrame2 = myPage.TextFrames.Item(iFrame2) 
    iTextFrame2.InsertionPoints.Item(-1).TextContents = sBuf4 & vbTab & sBuf5 
    iTextFrame2.Paragraphs.Item(1).Justification = idCenter 
    sBuf4 = rs!Number 
    myFile = "D:\Madison\" & sBuf4 & ".eps" 
    irFrame = "Photo-" & iPageCounter & "-" & myColumnCounter & "-" & myRowCounter 
    Set iRectFrame = myPage.Rectangles.Item(irFrame) 
    Rem uncomment if you have image files... 
    'iRectFrame.Place myFile 
    'iRectFrame.Fit idProportionally 
    'iRectFrame.Fit idCenterContent 
    rs.MoveNext 
Loop 

rs.Close 
End Function
Technical Details
Message-ID: <1de69529.37@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!diablo.theplanet.net!newsfeed.esat.net!feeder.news.heanet.ie!surfnet.nl!solnet.ch!solnet.ch!news.imp.ch!news.imp.ch!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de69529.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,4348409c0a586298
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-11-19 16:52:42 PST
From: maxdunn <maxdunn@siliconpublishing.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!diablo.theplanet.net!newsfeed.esat.net!feeder.news.heanet.ie!surfnet.nl!solnet.ch!solnet.ch!news.imp.ch!news.imp.ch!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Database Driven Catalog - ???
Message-ID: <1de69529.37@WebX.la2eafNXanI>
Date: Tue, 19 Nov 2002 14:06:18 -0800
References: <1de69529.-1@WebX.la2eafNXanI>
Lines: 135
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit