🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15492

Re: [VB] How to create table and populate

#15492
From: Eelko_Heuvelmans
Date: Fri, 05 Dec 2003 08:44
60 lines
3045 bytes
Here some info on tables i have collected when experimenting with it lately... I hope you can do something with it:

Tables should be inside a textframe. Otherwise you can't genreate one.
So make sure you have a valid textframe in your indesign document and add a table.
Here is how: (and some more, don't know of this compiles at once:))

IndesignInstance.Documents.add 'indesigninstance is the reference to your application
mydocument = IndesignInstance.ActiveDocument

dim dp as object = mydocument.DocumentPreferences
Dp.pagewidth = 210	'width of pages in new doc (A4)
Dp.PageHeight = 297

'place textframe container
myDocument.Pages.Item(1).TextFrames.Add	'add frame to page 1
myTextFrame = myDocument.Pages.Item(1).TextFrames.Item(1)
'myTextFrame.Label = "Some label, if needed"
'myTextFrame.GeometricBounds = FrameSize 'use pagesize here so frame spreads over the wholepage (if you want an fullpage table..)
'myTextFrame.Move(Position as array of object(containing integers)) (If you live move the frame to some position

'THIS IS ONE WAY......
''add table to text frame,
myTextFrame.Tables.Add(InDesign.idLocationOptions.idAtEnd)
myTable = myTextFrame.Tables.Item(1)

dim mycol as InDesign.Column
dim myrow as InDesign.Row

'THIS IS AN OTHER WAY TO ADD A TABLE
myTextFrame = mydocument.TextFrames.Item(1)
mytable = myTextFrame.Tables.Item(1)

myTextFrame.Tables.Add()
myTable = mydocument.Pages.Item(nPageNr).textFrames.Item(1).Tables.Item(1)

'When you have created the table, and you have a reference to it (myTable), Start setting the number of rows and columns

myTable.RowCount = 3 	
myTable.ColumnCount = 3		

'Finished creating table.
'Remember that the table still needs formatting, like column width and so on..

'Acces rows and columns like this:
Dim idCell as Indesign.Cell
idCell = myTable.Rows.item(1).Cells.Item(1) 'the cell on pos 1,1
idCell.TextContents = "The text in the first cell"

'get next cell
idCell = myTable.Rows.Item(2).Cells.Item(2) 'the second cel in row two position 2,2
dim imgPath as Object = "c:/images/image1.jpg" 'a path to an image
idCell.Place(imgPath) 'place an image in a cell


Well for so far,
I'll just made this one up, i'm quit sure that it is almost runable,.. At least!!! IF you use vb.NET
For vb6 it needs some modifications, but i'm sure that that won't be a problem.

Keep us informed!
Eelko
Technical Details
Message-ID: <2ccebcfa.1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2ccebcfa.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,b933a7649366945d
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-12-05 01:07:38 PST
From: Eelko_Heuvelmans@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: [VB] How to create table and populate
Message-ID: <2ccebcfa.1@webx.la2eafNXanI>
Date: Fri, 5 Dec 2003 00:44:25 -0800
References: <2ccebcfa.-1@webx.la2eafNXanI>
Lines: 71
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit