Article View: adobe.scripting.indesign
Article #19815Re: Database Driven Catalog - ???
From: Brian C. Carter
Date: Fri, 15 Nov 2002 21:40
Date: Fri, 15 Nov 2002 21:40
155 lines
6373 bytes
6373 bytes
Somehow I was able to get it to work. Don't ask me how though. Perhaps it was a typo, although I think it was more old code that thought I'd remarked out getting in the way.
It only goes up to 1 page though, and then starts returning error messages. So naturally I want it to add pages, however Im not sure how to go about doing that and having it perform the page setup again on the next page. Here's where I am now
===========================
Public Function SetupPage(myPage, iPage)
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myDocument = myInDesign.ActiveDocument
'Set myPage = myDocument.Pages.Item(1)
Set myPage = myDocument.Pages.Add
myPage.AppliedMaster = myDocument.MasterSpreads.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 / 4))
SR1T = (R1B - (myRH / 8))
PR2B = (R2T + (myRH / 4))
SR2T = (R2B - (myRH / 8))
PR3B = (R3T + (myRH / 4))
SR3T = (R3B - (myRH / 8))
PR4B = (R4T + (myRH / 4))
SR4T = (R4B - (myRH / 8))
myPageCounter = 1
myColumnCounter = 0
myRowCounter = 0
Do
Do
myTop = ((myRowCounter * myRH) + (myGutter * myRowCounter)) + myMarginTop
myBottom = ((((myRowCounter + 1) * myRH) + (myGutter * myRowCounter)) + myMarginTop)
myColumnCounter = 0
Do
myLeft = ((myColumnCounter * myCW) + (myGutter * myColumnCounter)) + myMarginLeft
myRight = (((myColumnCounter + 1) * myCW) + (myGutter * myColumnCounter)) + myMarginLeft
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
myTextFrame.GeometricBounds = Array(myTop, myLeft, myTop + (myRH / 4), myRight)
myTextFrame.Label = "Name-" & myPage & myColumnCounter + 1 & "-" & myRowCounter + 1
Set myTextFrame2 = myDocument.Pages.Item(1).TextFrames.Add
myTextFrame2.GeometricBounds = Array(myBottom - (myRH / 8), myRight, myBottom, myLeft)
myTextFrame2.Label = "Info-" & myPage & myColumnCounter + 1 & "-" & myRowCounter + 1
Set myRectangle1 = myDocument.Pages.Item(1).Rectangles.Add
myRectangle1.GeometricBounds = Array(myTop + (myRH / 4), myLeft, myBottom - (myRH / 8), myRight)
myRectangle1.Label = "Photo-" & myPage & myColumnCounter + 1 & "-" & myRowCounter + 1
myColumnCounter = myColumnCounter + 1
If myColumnCounter = 4 Then
Exit Do
End If
Loop
myRowCounter = myRowCounter + 1
If myRowCounter = 4 Then
Exit Do
End If
Loop
If myRowCounter = 4 Then
Exit Do ': Set myPage = myDocument.Pages.Add
End If
Loop
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)
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myDocument = myInDesign.ActiveDocument
'Set myPage = myDocument.Pages.Item(iPage)
iPage = 1
'Set myTextFrames = myDocument.Pages.Item(1)
myPageCounter = 1
myColumnCounter = 0
myRowCounter = 0
SetupPage myPage, 1
Do While Not rs.EOF
Do
sBuf1 = rs!Pre
sBuf2 = rs!Description
sBuf3 = rs!Sub
iFrame = "Name-" & myPage & myColumnCounter + 1 & "-" & myRowCounter + 1
Set iTextFrame = myPage.TextFrames.Item(iFrame)
iTextFrame.InsertionPoints.Item(-1).TextContents = sBuf1 & vbCr & sBuf2 & vbCr & sBuf3
sBuf4 = rs!Number
sBuf5 = rs!Pak
iFrame = "Info-" & myPage & myColumnCounter + 1 & "-" & myRowCounter + 1
Set iTextFrame = myPage.TextFrames.Item(iFrame)
iTextFrame.InsertionPoints.Item(-1).TextContents = sBuf4 & vbTab & sBuf5
rs.MoveNext
myColumnCounter = myColumnCounter + 1
If myColumnCounter = 4 Then
myColumnCounter = 0: myRowCounter = myRowCounter + 1
End If
Loop
myRowCounter = myRowCounter + 1
If myRowCounter = 4 Then
myPageCounter = myPageCounter + 1
SetupPage myPage, iPage
Else
End If
Loop
rs.Close
End Function
================================
I've tried several places (as you can see). Where should the add page command go, and where should the page setup command go?
Its been a very busy Friday for me.
Technical Details
Message-ID:
<1de69529.21@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-04!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<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 14:23:24 PST From: "Brian C. Carter" <brian@samardist.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-04!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Database Driven Catalog - ??? Message-ID: <1de69529.21@WebX.la2eafNXanI> Date: Fri, 15 Nov 2002 13:40:03 -0800 References: <1de69529.-1@WebX.la2eafNXanI> Lines: 178 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit