Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27189

VS 2010 Generate Word file - pagenumber in table in header

$
0
0
Hello,

I'm trying to put the pagenumbre in a cell of a table, which table is standing in the header of a generated Word document. With the code below, the page number appaers always in the first cell and not in the correct one. What is wrong with my code?

Jody

With oDoc.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range
With .Tables.Add(oDoc.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range, 2, 4)
.Cell(1, 1).Range.Text = FindText(40)
.Cell(1, 2).Range.Text = FindText(41)
.Cell(1, 3).Range.Text = FindText(42)
.Cell(1, 4).Range.Text = FindText(43)

.Cell(2, 1).Range.Text = Frm_Main.Txt_Company.Text
.Cell(2, 2).Range.Text = Frm_Main.Txt_OurRef.Text
.Cell(2, 3).Range.Text = time.ToString(format)
Dim CurrentPage As Object = Word.WdFieldType.wdFieldPage
.Cell(2, 4).Range.Fields.Add(oDoc.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range, CurrentPage) '<== pagenumber

.Columns.Item(1).Width = oWord.CentimetersToPoints(6)
.Columns.Item(2).Width = oWord.CentimetersToPoints(6.6)
.Columns.Item(3).Width = oWord.CentimetersToPoints(3)
.Columns.Item(4).Width = oWord.CentimetersToPoints(2.31)

End With
End With

Viewing all articles
Browse latest Browse all 27189

Trending Articles