Generate dynamic tables for word by code in VB.net

0

Hi boy, I have a query that I am generating a table for a word document using code, I have a word that I use as the base where the title comes from, a paragraph and a row with 5 columns that are the heading I want for the table that genre by vb.net, then I want you to insert the table, the table is inserted by code and not with labels because it is a variable table since it can have N rows my code is as follows

   Dim rng As Word.Range = oDoc.Application.ActiveDocument.Range(Start:=474, End:=474) // en esta linea declaro la tabla y con range le indico donde posicionarse
                        With rng
                            With .Font
                                .Name = "calibri light"
                            End With
                            .Font.Size = 10
                            .SetRange(rng.End, rng.End)
                        End With
                        'contadoint += 2
                        rng.Tables.Add(Range:=rng, NumRows:=contadoint, NumColumns:=5)
                        With rng.Tables.Item(1)
                            .Range.Font.Size = 11
                            .Borders(Word.WdBorderType.wdBorderBottom).LineStyle = Word.WdLineStyle.wdLineStyleSingle
                            .Borders(Word.WdBorderType.wdBorderLeft).LineStyle = Word.WdLineStyle.wdLineStyleSingle
                            .Borders(Word.WdBorderType.wdBorderRight).LineStyle = Word.WdLineStyle.wdLineStyleSingle
                            .Borders(Word.WdBorderType.wdBorderTop).LineStyle = Word.WdLineStyle.wdLineStyleSingle
                            .Borders(Word.WdBorderType.wdBorderHorizontal).LineStyle = Word.WdLineStyle.wdLineStyleSingle
                            .Borders(Word.WdBorderType.wdBorderVertical).LineStyle = Word.WdLineStyle.wdLineStyleSingle
                            .Columns.DistributeWidth()
                        End With

my problem is that when using range also the place where the table derrepente is generated is generated in the position I want but depending on the rows and other data the order is disarmed, what I would like is to fix a position and that is believed from there

beforehand thank you very much

    
asked by Pablo Moraga 25.05.2017 в 01:35
source

0 answers