<
[email protected]>
<VA.00000813.018f4aa0@speedy>
<
[email protected]>
Newsgroups: microsoft.public.office.developer.automation
NNTP-Posting-Host: 223.202.77.83.cust.bluewin.ch 83.77.202.223
Lines: 1
Path: number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!msrtrans!TK2MSFTFEEDS01.phx.gbl!TK2MSFTFEEDS02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
Xref: number1.nntp.dca.giganews.com microsoft.public.office.developer.automation:12515
Hi Giddy,
By default, borders won't usually be applied. From Word 2003 onwards, it
will depend on what Table Style the user may have selected as the default
(although most users never find that option). Whether or not gridlines
(which don't print) are applied depends on the setting of that option in
the Table menu.
So, you should apply any formatting you require to the table, after you
create it. (My article mainly focusses on getting data into tables.
Covering more than that could result in an entire book
!)
You basically have three choices for formatting tables
1. Apply direct formatting. At first glance, this will seem the easiest
thing to do. But if your document contains more than one table, it will
be the slowest in the long run.
2. Use one of Word's built-in Table AutoFormat styles. You can look at
these through Table/AutoFormat. Note that you can select WHAT part of the
format is to be applied, and whether to apply it to the first and last
rows/columns. If you find one of these that does the job for you, record
applying it to a table in a macro to get the basic syntax.
3. Create your own Table Style. This will be the most difficult to code,
but give you the most flexibility combined with speed (vs. (1)).
I was mistaken , my clients have office 2000! i coaxed them into
getting office 2003! So i dont need to worry about late binding for
now!
i ran the sample code you have on your article , it works perfect ,
BUT! when i tried to make my own little function it does'nt work ,
word fires up , the DATA shows up in word with no table borders! i have
word 2007 .. heres what it looks like ->
gidisrael.googlepages.com/wdAutomation.jpg
could you please tell me what i'm doing wrong , i've been studying your
code for days now and i still cant figure it out!
this is my code :
private void button1_Click(object sender, EventArgs e)
{
object objMissing = System.Reflection.Missing.Value;
object objTrue = true;
wd.ApplicationClass objWord = new wd.ApplicationClass();
objWord.Visible = true;
wd.Document objDoc = objWord.Documents.Add(ref objMissing,
ref objMissing,ref objMissing, ref objTrue);
wd.Range objRange = objDoc.Content;
wd.Table tbl = objDoc.Tables.Add(objRange, 4,4, ref
objDefaultBehaviorWord8, ref objAutoFitFixed);
int r = 1;
while (r<=4)
{
for (int nrCol = 1; nrCol <= 4; nrCol++)
{
// Now add the records.
tbl.Cell(r, nrCol).Range.Text =
Convert.ToString("Num" + nrCol);
}
r++;
}
}
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail