Basicfarmer
asked on
Lines between word tables in VB.NET
Experts, I am working with Word tables in VB.Net. I have three tables on one page. The only way I could figure out how to leave one table and insert a new table was to use this little bit of code here. But this leaves me with a line between the tables. Is there a way to create a table directly after the previous table? It would look like one table but would be multiple tables.
oWord.Selection.EndKey(Wor d.WdUnits. wdStory)
oWord.Selection.TypeParagr aph()
oWord.Selection.EndKey(Wor
oWord.Selection.TypeParagr
ASKER
Thanks for the reply. Here is the code I am using to create the table. The only way I could figure out how to get out of the table was with what I showed previously. As soon as this table is created then I will build another table. I will do this several times. I want the tables not to have a blank line between them. The tables will all have the same structure.
'<Build totals table>
Dim totalsTable As Word.Table = odoc.Tables.Add(oWord.Selection.Range, 3, 4)
With totalsTable
.Range.Font.Name = "Calibri"
.Range.Font.Size = 9
.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle
.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle
.Rows(1).Shading.BackgroundPatternColor = CType(RGB(110, 110, 100), Word.WdColor)
.Rows(1).Range.Font.ColorIndex = Word.WdColorIndex.wdWhite
.Rows(1).Range.Font.Bold = 1
.Rows(2).Shading.BackgroundPatternColor = CType(RGB(134, 39, 61), Word.WdColor)
.Rows(2).Range.Font.ColorIndex = Word.WdColorIndex.wdWhite
.Rows(2).Range.Font.Bold = 1
.Cell(1, 1).Merge(.Cell(1, 4))
.Cell(1, 1).Range.Text = "PROPOSED TOTALS"
.Cell(2, 1).Range.Text = "SYSTEM VALUE"
.Cell(2, 2).Range.Text = "VALUED CUSTOMER DISCOUNT"
.Cell(2, 3).Range.Text = "SAVINGS"
.Cell(2, 4).Range.Text = "SYSTEM PRICE"
.Cell(3, 1).Range.Text = CDec(projectList(projectRow)).ToString("C2")
.Cell(3, 2).Range.Text = CDec(projectDiscount(projectRow)).ToString("P2")
.Cell(3, 3).Range.Text = CDec(projectDiscountAmount(projectRow)).ToString("C2")
.Cell(3, 4).Range.Text = CDec(projectSell(projectRow)).ToString("C2")
End With
'</Build totals table>
If the tables have the same structure and you do not want them to be separated, why don't you simply go on in the same table?
ASKER
The tables are grouped products. The user has the option to subtotal each group. If the groups are not subtotaled this is when i want to put the tables together. If the groups are subtotaled then i will leave the space between the tables. I can use the same loop for both conditions if I can eliminate the space between tables.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, that was exactly what I needed...
You should show more of the code, before and after these 2 lines.
In the meanwhile, you might try to replace TypeParagraph() by TypeText Chr(11). This is simply a change of line instead of a paragraph, so it might do the trick, depending on how you are set in the document.