 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Quin Guest
|
Posted: Thu Jan 22, 2004 12:04 pm Post subject: Table in Word |
|
|
Hi
D7
VCL Server components for Word
Word2k
How can I add a 2 column table and populate the cells with text?
The number of rows will be variable.
Thanks
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Thu Jan 22, 2004 8:35 pm Post subject: Re: Table in Word |
|
|
1. create table
table := document.Range.Tables.Add(Range :=
document.Range(document.Content.End-1, document.Content.End-1), NumRows :=
1, NumColumns := 2);
2. add new row
table.Rows.Add
3. set a value for cell
table.Cell(RowNum, ColNum).Range.InsertAfter('your text');
PS: I used a syntax for late binding but code for server components is
similar...
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Quin" <qWin (AT) the-host (DOT) net> wrote
| Quote: | Hi
D7
VCL Server components for Word
Word2k
How can I add a 2 column table and populate the cells with text?
The number of rows will be variable.
Thanks
|
|
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Tue Mar 02, 2004 12:10 pm Post subject: Re: Table in Word |
|
|
<
WordApp.ActiveDocument.Tables.Add(
WordApp.ActiveDocument.Range, GRowCount+1, GColCount)
but when I insert the table all the rest comes cancelled!
Yes, because you passed the whole range of the document to
the Tables.Add method. Whatever range you pass in will
have its content replaced by the table, so if you don't
want any text to be replaced, you have to make sure you
pass an empty range. The Collapse method is useful here.
This example adds a table at the end of a document:
var
R: Range;
Direction: OleVariant;
...
Direction := wdCollapseEnd;
R := Doc.Content;
R.Collapse(Direction);
Tbl := Doc.Tables.Add(R, 2, 4, EmptyParam, EmptyParam);
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|