🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #19915

Re: Database Driven Catalog - ???

#19915
From: maxdunn
Date: Thu, 14 Nov 2002 18:26
88 lines
4596 bytes
That's kind of strange, you don't usually think so much in terms of which record number it is, but rather flow sequentially and make decisions based on field name and context in the flow. Anyway, as a general example, here's some code that puts even records into text frames 1 and 2, and odd records into text frames 3 and 4. Not that someone would really do this... 

Option Compare Database 

Public Function SetupPage(oPage, iPage) 
    Rem Make the X textboxes on a new page 
    Rem Takes the page object and the page number 
    Rem DOESNT thread the frames... 
    Set oDocument = oPage.Parent.Parent 
    iColumns = oPage.MarginPreferences.ColumnCount 
    dPageWidth = oDocument.DocumentPreferences.PageWidth 
    dPageHeight = oDocument.DocumentPreferences.PageHeight 
    dGutter = oPage.MarginPreferences.ColumnGutter 
    If iPage Mod 2 = 0 Then 
        dMarginRight = oPage.MarginPreferences.MarginLeft 
        dMarginLeft = oPage.MarginPreferences.MarginRight 
    Else 
        dMarginRight = oPage.MarginPreferences.MarginRight 
        dMarginLeft = oPage.MarginPreferences.MarginLeft 
    End If 
    dMarginTop = oPage.MarginPreferences.MarginTop 
    dMarginBottom = oPage.MarginPreferences.MarginBottom 
    dColumnWidth = (dPageWidth - (dMarginRight + dMarginLeft) _ 
        - (dGutter * (iColumns - 1))) / iColumns 
    dY1 = dMarginTop 
    dY2 = dPageHeight - dMarginBottom 
    For i = 1 To iColumns 
        dOffset = (i - 1) * (dColumnWidth + dGutter) 
        dX1 = dMarginLeft + dOffset 
        dX2 = dX1 + dColumnWidth 
        Set oTextFrame = oPage.TextFrames.Add 
        oTextFrame.GeometricBounds = Array(dY1, dX1, dY2, dX2) 
        oTextFrame.Label = "TF_" & iPage & "_" & i 
        If i = 1 Then 
            Set SetupPage = oTextFrame 
        End If 
    Next 
End Function 
Public Function Output() 
    Dim db As DAO.Database 
    Dim rs As DAO.Recordset 
    Set db = CurrentDb 
    Set rs = db.OpenRecordset("tblMyTable", dbOpenDynaset) 
    Dim oInDesign As InDesign.Application 
    Set oInDesign = CreateObject("InDesign.Application.2.0") 
    Set oDocument = oInDesign.Documents.Add 
    Set oPage = oDocument.Pages.Item(1) 
    Set oPrevTextFrame = Nothing 
    SetupPage oPage, 1 
    iPage = 1 
    iCounter = 0 
    Do While Not rs.EOF 
        iCounter = iCounter + 1 
        If Not iCounter Mod 2 = 0 Then 
            ' Every other record will be in different 
            ' text frames... 
            sBuf = rs!myField1 
            Rem this one goes in the first frame 
            sFrame = "TF_" & iPage & "_1" 
            Set oTextFrame = oPage.TextFrames.Item(sFrame) 
            oTextFrame.InsertionPoints.Item(-1).TextContents = sBuf _ 
                & vbCr 
            sBuf = rs!myField2 
            Rem this one goes in the second frame 
            sFrame = "TF_" & iPage & "_2" 
            Set oTextFrame = oPage.TextFrames.Item(sFrame) 
            oTextFrame.InsertionPoints.Item(-1).TextContents = sBuf _ 
                & vbCr 
        Else 
            sBuf = rs!myField1 
            Rem this one goes in the third frame 
            sFrame = "TF_" & iPage & "_3" 
            Set oTextFrame = oPage.TextFrames.Item(sFrame) 
            oTextFrame.InsertionPoints.Item(-1).TextContents = sBuf _ 
                & vbCr 
            sBuf = rs!myField2 
            Rem this one goes in the fourth frame 
            sFrame = "TF_" & iPage & "_4" 
            Set oTextFrame = oPage.TextFrames.Item(sFrame) 
            oTextFrame.InsertionPoints.Item(-1).TextContents = sBuf _ 
                & vbCr 
        End If 
        Rem probably add pages based on some condition here 
        rs.MoveNext 
    Loop 
    rs.Close 
    Set rs = Nothing 
End Function
Technical Details
Message-ID: <1de69529.11@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newspump.sol.net!news.maxwell.syr.edu!news-hub.siol.net!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-14 10:44:04 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-08!supernews.com!newspump.sol.net!news.maxwell.syr.edu!news-hub.siol.net!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.11@WebX.la2eafNXanI>
Date: Thu, 14 Nov 2002 10:26:55 -0800
References: <1de69529.-1@WebX.la2eafNXanI>
Lines: 93
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit