BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Table in Word

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Quin
Guest





PostPosted: Thu Jan 22, 2004 12:04 pm    Post subject: Table in Word Reply with 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
Mike Shkolnik
Guest





PostPosted: Thu Jan 22, 2004 8:35 pm    Post subject: Re: Table in Word Reply with quote



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





PostPosted: Tue Mar 02, 2004 12:10 pm    Post subject: Re: Table in Word Reply with quote



< WordApp.ActiveDocument.Tables.Add(
WordApp.ActiveDocument.Range, GRowCount+1, GColCount)

but when I insert the table all the rest comes cancelled!
Quote:


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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.