Formatting table is not working?

M

Mustafa Karakas

Hi all;

I'm writing a code that creates a word document, creates tables and puts
data in to the tables. I'm formatting table and its columns with
PreferredwidthType and PreferredWidth properties. but some of tables are not
beeing that I formatted. Why
this could be ? (case: there are tree table. they are in same format. first
two one is good, but the third one is not beeing that I want.)

Here is a part of code:
oAppWord.Selection.WholeStory
oAppWord.Selection.Collapse 0 'wdCollapseEnd
oAppWord.Selection.TypeParagraph
oAppWord.Selection.TypeParagraph

Set oRange = oAppWord.Selection.Range
oRange.SetRange oAppWord.Selection.Range.End, oAppWord.Selection.Range.End
Set oTable = oAppWord.Selection.Tables.Add(oRange, 2, 2)

oTable.AllowAutoFit = False
oTable.AutoFormat 0 ' wdTableFormatNone
oTable.PreferredWidthType = 1 '1:wdPreferredWidthPoints
oTable.PreferredWidth = 300
oTable.Columns(1).PreferredWidthType = 2 '2:wdPreferredWidthPercent
oTable.Columns(1).PreferredWidth = 40
oTable.Rows(1).Cells.Merge
oTable.Cell(1, 1).Range.Style = -67 '(&HFFFFFFBD) wdStyleBodyText
oTable.Cell(1, 1).Range.Text = "Caption"

oTable.Cell(2, 1).Range.Style = -4 '(&HFFFFFFFC) wdStyleHeading3
oTable.Cell(2, 1).Range.Text = "Headaer 1"
oTable.Cell(2, 2).Range.Style = -5 ' (&HFFFFFFFB) wdStyleHeading4
oTable.Cell(2, 2).Range.Text = "Headaer 1"
.....

The tables width and columns width are not line that I give?
Is there any formatting problem?

ps:sorry for bad english
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top