🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #19803

Re: Database Driven Catalog - ???

#19803
From: Brian C. Carter
Date: Fri, 15 Nov 2002 15:10
189 lines
8372 bytes
Mostly to force myself to have to learn, I tried writing a script like this from scratch. I am very pleased to say that within a day I had a functioning script. However it is not as functional as I would like, for the one thing, I have to specify each text box (which I don't think I can get around, but I want to make it automatically add a page when it is full and Im not sure how to do this. Note, I Remarked some things out for simplicity when testing such as the loop. Also I have some things left over from abortive attempts at things (such as the counter) and my co-ordinates aren't def correct for anything beyond Row 2. I guess high school was right, you DO need Algebra for some things. 

Also, if I have a Null value in a field can I make it NOT put in a vbcr before the next field? 

Anyway, any advice? suggestions? Many thanks to Max for the scripts that showed me how to do it. 
==================================== 
Public Function Putout() 
Dim db As DAO.Database 
Dim rs As DAO.Recordset 
Set db = CurrentDb 
Set rs = db.OpenRecordset("Ordered", dbOpenDynaset) 

Dim myInDesign As InDesign.Application 
Set myInDesign = CreateObject("InDesign.Application.2.0") 
Set myDocument = myInDesign.ActiveDocument 
Set myPage = myDocument.Pages.Item(1) 
myPageWidth = myDocument.DocumentPreferences.PageWidth 
myPageHeight = myDocument.DocumentPreferences.PageHeight 
myInDesign.ActiveDocument.ViewPreferences.HorzMeasurementUnits = idMSInches 
myInDesign.ActiveDocument.ViewPreferences.VertMeasurementUnits = idMSInches 
myMarginLeft = myPage.MarginPreferences.MarginLeft 
myMarginTop = myPage.MarginPreferences.MarginTop 
myMarginRight = myPage.MarginPreferences.MarginRight 
myMarginBottom = myPage.MarginPreferences.MarginBottom 
myGutter = myPage.MarginPreferences.ColumnGutter 
myColumns = myPage.MarginPreferences.ColumnCount 
myRows = 4 
myCW = (((myPageWidth - (myMarginLeft + myMarginRight)) - (myGutter * (myColumns - 1))) / myColumns) 
myRH = ((myPageHeight - (myMarginTop + myMarginBottom + (myGutter * (myColumns - 1)))) / myRows) 

C1L = myMarginLeft 
C1R = myMarginLeft + (myCW) 
C2L = (myMarginLeft + (myCW + myGutter)) 
C2R = (myMarginLeft + ((2 * myCW) + myGutter)) 
C3L = (myMarginLeft + ((2 * myCW) + (2 * myGutter))) 
C3R = (myMarginLeft + ((3 * myCW) + (2 * myGutter))) 
C4L = (myMarginLeft + ((3 * myCW) + (3 * myGutter))) 
C4R = (myMarginLeft + ((4 * myCW) + (3 * myGutter))) 

R1T = myMarginTop 
R1B = myMarginTop + myRH 
R2T = myMarginTop + myRH + myGutter 
R2B = myMarginTop + (2 * (myRH) + myGutter) 
R3T = myMarginTop + (2 * (myRH + myGutter)) 
R3B = myMarginTop + (3 * (myRH + myGutter)) 
R4B = myMarginTop + (3 * myRH) + myGutter 
R4B = myMarginTop + (4 * (myRH + myGutter)) 

PR1B = (R1T + (myRH / 3)) 
SR1T = (R1B - (myRH / 8)) 
PR2B = (R2T + (myRH / 3)) 
SR2T = (R2B - (myRH / 8)) 
PR3B = (R3T + (myRH / 3)) 
SR3T = (R3B - (myRH / 8)) 
PR4B = (R4T + (myRH / 3)) 
SR4T = (R4B - (myRH / 8)) 

myTextWidth = "1.75i" 

Rem Do While Not rs.EOF 
    myCounter = 1 
    Rem If myCounter = >16 Then myDocument.Pages.Item.Add Else Nothing 

sBuf1 = rs!Pre 
    sBuf2 = rs!Description 
    sBuf3 = rs!Sub 
    sBuf4 = rs!Number 
    sBuf5 = rs!Pak 

Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame.GeometricBounds = Array(R1T, C1L, PR1B, C1R) 
    myTextFrame.TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3 
    Set myTextFrame2 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame2.GeometricBounds = Array(SR1T, C1L, R1B, C1R) 
    myTextFrame2.TextContents = sBuf4 & vbTab & sBuf5 
    myCounter = myCounter + 1 



rs.MoveNext 
    sBuf1 = rs!Pre 
    sBuf2 = rs!Description 
    sBuf3 = rs!Sub 
    sBuf4 = rs!Number 
    sBuf5 = rs!Pak 

Set myTextFrame3 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame3.GeometricBounds = Array(R1T, C2L, (myMarginTop + myRH / 3), C2R) 
    myTextFrame3.TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3 
    Set myTextFrame4 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame4.GeometricBounds = Array(SR1T, C2L, R1B, C2R) 
    myTextFrame4.TextContents = sBuf4 & vbTab & sBuf5 
    myCounter = myCounter + 1 

rs.MoveNext 
    sBuf1 = rs!Pre 
    sBuf2 = rs!Description 
    sBuf3 = rs!Sub 
    sBuf4 = rs!Number 
    sBuf5 = rs!Pak 

Set myTextFrame5 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame5.GeometricBounds = Array(R1T, C3L, PR1B, C3R) 
    myTextFrame5.TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3 
    Set myTextFrame6 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame6.GeometricBounds = Array(SR1T, C3L, R1B, C3R) 
    myTextFrame6.TextContents = sBuf4 & vbTab & sBuf5 
    myCounter = myCounter + 1 

rs.MoveNext 
    sBuf1 = rs!Pre 
    sBuf2 = rs!Description 
    sBuf3 = rs!Sub 
    sBuf4 = rs!Number 
    sBuf5 = rs!Pak 

Set myTextFrame7 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame7.GeometricBounds = Array(R1T, C4L, PR1B, C4R) 
    myTextFrame7.TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3 
    Set myTextFrame8 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame8.GeometricBounds = Array(SR1T, C4L, R1B, C4R) 
    myTextFrame8.TextContents = sBuf4 & vbTab & sBuf5 
    myCounter = myCounter + 1 

rs.MoveNext 
    sBuf1 = rs!Pre 
    sBuf2 = rs!Description 
    sBuf3 = rs!Sub 
    sBuf4 = rs!Number 
    sBuf5 = rs!Pak 

Set myTextFrame9 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame9.GeometricBounds = Array(R2T, C1L, PR2B, C1R) 
    myTextFrame9.TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3 
    Set myTextFrame10 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame10.GeometricBounds = Array(SR2T, C1L, R2B, C1R) 
    myTextFrame10.TextContents = sBuf4 & vbTab & sBuf5 
    myCounter = myCounter + 1 

rs.MoveNext 
    sBuf1 = rs!Pre 
    sBuf2 = rs!Description 
    sBuf3 = rs!Sub 
    sBuf4 = rs!Number 
    sBuf5 = rs!Pak 

Set myTextFrame11 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame11.GeometricBounds = Array(R2T, C2L, PR2B, C2R) 
    myTextFrame11.TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3 
    Set myTextFrame12 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame12.GeometricBounds = Array(SR2T, C2L, R2B, C2R) 
    myTextFrame12.TextContents = sBuf4 & vbTab & sBuf5 
    myCounter = myCounter + 1 

rs.MoveNext 
    sBuf1 = rs!Pre 
    sBuf2 = rs!Description 
    sBuf3 = rs!Sub 
    sBuf4 = rs!Number 
    sBuf5 = rs!Pak 

Set myTextFrame12 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame12.GeometricBounds = Array(R2T, C3L, PR2B, C3R) 
    myTextFrame12.TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3 
    Set myTextFrame13 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame13.GeometricBounds = Array(SR2T, C3L, R2B, C3R) 
    myTextFrame13.TextContents = sBuf4 & vbTab & sBuf5 
    myCounter = myCounter + 1 

rs.MoveNext 
    sBuf1 = rs!Pre 
    sBuf2 = rs!Description 
    sBuf3 = rs!Sub 
    sBuf4 = rs!Number 
    sBuf5 = rs!Pak 
    Set myTextFrame14 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame14.GeometricBounds = Array(R2T, C4L, PR2B, C4R) 
    myTextFrame14.TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3 
    Set myTextFrame15 = myDocument.Pages.Item(1).TextFrames.Add 
    myTextFrame15.GeometricBounds = Array(SR2T, C4L, R2B, C4R) 
    myTextFrame15.TextContents = sBuf4 & vbTab & sBuf5 
    myCounter = myCounter + 1 

Rem Loop 

rs.Close 

End Function 
===============================
Technical Details
Message-ID: <1de69529.14@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!newsswitch.lcs.mit.edu!newsfeed.cwix.com!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-15 07:58:02 PST
From: "Brian C. Carter" <brian@samardist.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!newsswitch.lcs.mit.edu!newsfeed.cwix.com!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.14@WebX.la2eafNXanI>
Date: Fri, 15 Nov 2002 07:10:41 -0800
References: <1de69529.-1@WebX.la2eafNXanI>
Lines: 202
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit