Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Formatting and column width problems
I am creating a table from a database. I must create each row and populate as
each record is read since for some records I only need 2 columns and some I need 3. I accomplis this through setting the column width of column 2 as 425 with the ruler style to Adust Proportional. Additionally, I need column 1 as bold and records that are section headers get an Arial Bold font and cell shading. The problem is that if I only write 1 row, the formatting works fine, but when I read in the entire database, the formatting goes away when the next row is written. I am wondering if it is a range problem. After I create a new row, I collapse my range before writing to the contents of the 3 cells. But if I dont collapse, my next row is written to cell 1 and so on. Here is the code that writes the table If GroupPrint = "Yes" Then Set brng = ActiveDocument.Range brng.Collapse wdCollapseEnd ActiveDocument.Tables.Add Range:=brng, NumRows:=1, NumColumns:=3 With ActiveDocument.Tables.Item(1) .Borders.Enable = True .Range.Font.Name = "Times New Roman" .Shading.Texture = wdTextureNone .Range.Font.Size = "12" .Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft If PrintData(1) "" Then 'Prints Section Heading With .Cell(Row:=lrows, Column:=1) .Range.Text = PrintData(1) .SetWidth ColumnWidth:=500, RulerStyle:=wdAdjustProportional .Shading.Texture = wdTexture90Percent .Range.Font.Color = wdColorWhite End With With .Cell(Row:=lrows, Column:=2) .Shading.Texture = wdTexture90Percent End With With .Cell(Row:=lrows, Column:=3) .Shading.Texture = wdTexture90Percent End With Else If PrintData(3) "" Then 'Prints row XP With .Cell(Row:=lrows, Column:=1) .Range.Text = PrintData(2) .Range.Font.Name = "Times New Roman Bold" End With With .Cell(Row:=lrows, Column:=2) .Range.Text = PrintData(3) .SetWidth ColumnWidth:=425, RulerStyle:=wdAdjustProportional .Borders(wdBorderRight).Visible = False End With With .Cell(Row:=lrows, Column:=3) .Borders(wdBorderLeft).Visible = False End With Else If PrintData(5) = "" Then 'Prints row IN with no O With .Cell(Row:=lrows, Column:=1) .Range.Text = PrintData(2) .Range.Font.Name = "Times New Roman Bold" End With With .Cell(Row:=lrows, Column:=2) .Range.Text = PrintData(4) .SetWidth ColumnWidth:=425, RulerStyle:=wdAdjustProportional .Borders(wdBorderRight).Visible = False End With With .Cell(Row:=lrows, Column:=3) .Borders(wdBorderLeft).Visible = False End With Else 'Prints row IN with O With .Cell(Row:=lrows, Column:=1) .Range.Text = PrintData(2) .Range.Font.Name = "Times New Roman Bold" End With With .Cell(Row:=lrows, Column:=2) .Range.Text = PrintData(4) End With With .Cell(Row:=lrows, Column:=3) .Range.Text = PrintData(5) End With End If End If End If lrows = lrows + 1 End With End If Thanks in advance for any help anyone can give me |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Table width behavior | Tables | |||
Changing column width in copied text | Microsoft Word Help | |||
How to copy/paste column formatting between rows | Tables | |||
table column width problems | Tables | |||
Table column formatting | Tables |