If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#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 |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
column to column conditional formatting won't work, need formula | rrupp | Worksheet Functions | 1 | August 23rd, 2005 10:06 PM |
cell formatting problems | jazzsax505 | New Users | 2 | May 29th, 2005 10:30 PM |
Conditional formatting applicable to entire column | jackalx | Worksheet Functions | 1 | May 26th, 2005 05:20 PM |
conditional formatting based on column | snax500 | General Discussion | 4 | April 27th, 2005 06:13 PM |
formatting individual columns for different languages, including double-byte characters | Sandra Rosenzweig | General Discussion | 1 | June 20th, 2004 01:08 PM |