Article View: adobe.scripting.indesign
Article #16218Re: [VB] Beginner Questions
From: Olav_Kvern
Date: Thu, 02 Oct 2003 18:45
Date: Thu, 02 Oct 2003 18:45
71 lines
3559 bytes
3559 bytes
Peter--
Something like this?
Private Function myMain()
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myDocument = myInDesign.Documents.Add
Rem Create some paragraph styles.
Set myTitleStyle = myDocument.ParaStyles.Add
myTitleStyle.Name = "title"
Set myTableHeaderStyle = myDocument.ParaStyles.Add
myTableHeaderStyle.Name = "table_head"
Set myTableBodyStyle = myDocument.ParaStyles.Add
myTableBodyStyle.Name = "table"
Rem Create a text frame.
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
Rem Resize the text frame to the bounds of the page.
myTextFrame.GeometricBounds = myGetBounds(myDocument.Pages.Item(1))
Rem Build a string--we'll use it when we make the table
myString = ""
Rem I'm not sure how many rows you need, so I'll pick 10.
For myRowCounter = 1 To 10
For myColumnCounter = 1 To 11
myString = myString & CStr(myRowCounter) & ":" & CStr(myColumnCounter)
If myColumnCounter < 11 Then
myString = myString & vbTab
End If
Next
myString = myString + vbCr
Next
Set myStory = myTextFrame.ParentStory
For myCounter = 1 To 3
Set myInsertionPoint = myStory.InsertionPoints.Item(-1)
myInsertionPoint.ApplyStyle myTitleStyle, True
myInsertionPoint.TextContents = "Table Title." & vbCr
myStartIndex = myStory.InsertionPoints.Item(-1).Index
myStory.InsertionPoints.Item(-1).TextContents = myString
Set myStartCharacter = myStory.Characters.Item(myStartIndex)
Set myEndCharacter = myStory.Characters.Item(-2)
Set myText = myStory.Characters.ItemByRange(myStartCharacter, myEndCharacter).Item(1)
Set myTable = myText.Tables.Add
For myRowCounter = 1 To myTable.Rows.Count
Set myRow = myTable.Rows.Item(myRowCounter)
For myColumnCounter = 1 To myRow.Cells.Count
Set myCell = myRow.Cells.Item(myColumnCounter)
If myRowCounter = 1 Then
myCell.Texts.Item(1).ApplyStyle myTableHeaderStyle
Else
myCell.Texts.Item(1).ApplyStyle myTableBodyStyle
End If
Next
Next
Next myCounter
End Function
Private Function myGetBounds(myPage)
Set myDocument = myPage.Parent.Parent
myPageHeight = myDocument.DocumentPreferences.PageHeight
myPageWidth = myDocument.DocumentPreferences.PageWidth
myX1 = myPage.MarginPreferences.MarginLeft
myY1 = myPage.MarginPreferences.MarginTop
myY2 = myPageHeight - myPage.MarginPreferences.MarginBottom
myX2 = myPageWidth - myPage.MarginPreferences.MarginRight
myGetBounds = Array(myY1, myX1, myY2, myX2)
End Function
Thanks,
Ole
Technical Details
Message-ID:
<2ccd9766.0@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2ccd9766.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,612ea520b09973db X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-10-02 12:08:10 PST From: Olav_Kvern@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: [VB] Beginner Questions Message-ID: <2ccd9766.0@webx.la2eafNXanI> Date: Thu, 2 Oct 2003 11:45:18 -0700 References: <2ccd9766.-1@webx.la2eafNXanI> Lines: 70 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit