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

Word 2010 document Vb.net project

$
0
0
Hi I got the following I have a word 2010 document project in Vb.net which I creating I had no problem with the field that I wanna change using bookmarks however I want to insert a table to the project which is easy see the code below which I used to create the table. However my problem is I want to put the table on page 7 paragraph 4. My problem is this the table creates but its goes to page 1 at the to of the document anybody have an idea how to position the where the table is created. Is there a way to link that the table creates at a specific bookmark. Below is my code for creating the table as you can see I pulling the information out of a datagrid.

Private Sub Obligations()
Dim oApp As Word.Application
' Dim oDoc As Word.Document
Dim Rowcount As Integer
Dim rownumber As Integer
Rowcount = DataGridView4.RowCount
'Start a new document in Word
' Globals.ThisDocument.tblTable.Text = oApp.Activate
oApp = CType(CreateObject("Word.Application"), Word.Application)
' oDoc = oApp.Documents.Add()
' Set up the header information.
Dim rng As Word.Range = Globals.ThisDocument.Range(0, 0)
rng.Font.Name = "Verdana"
rng.Font.Size = 16
Dim tlb As Word.Table
tlb = Globals.ThisDocument.tblTable.Tables.Add(Range:=rng, NumRows:=4, NumColumns:=4)
'Filling data to table
'Header Row
tlb.Cell(1, 1).Range.Text = "Asset"
tlb.Cell(1, 2).Range.Text = "Approx. balance"
tlb.Cell(1, 3).Range.Text = "Instalment1"
tlb.Cell(1, 4).Range.Text = " Rescheduled Instalment"
'tlb.Borders(WdBorderType.wdBorderTop)
rownumber = Rowcount
Do Until Rowcount = -1
Rowcount = Rowcount - 1
If Rowcount = -1 Then
'Data Row
Else
If DataGridView3.Rows(Rowcount).Cells(2).Value = "" Then
Else
tlb.Cell(Rowcount + 1, 1).Range.Text = DataGridView4.Rows(Rowcount).Cells(0).Value
tlb.Cell(Rowcount + 1, 2).Range.Text = DataGridView4.Rows(Rowcount).Cells(1).Value
tlb.Cell(Rowcount + 1, 3).Range.Text = DataGridView4.Rows(Rowcount).Cells(2).Value
tlb.Cell(Rowcount + 1, 4).Range.Text = DataGridView4.Rows(Rowcount).Cells(3).Value
tlb.Cell(Rowcount + 1, 4).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight
End If
End If
Loop
End Sub

Viewing all articles
Browse latest Browse all 27389

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>