How to inserr a row in word document template as dynamically using vb.net

victor_Athoti

New Member
Joined
May 10, 2012
Messages
1
Hi all,
i am new to this forum,i have create one word document template by manually and add the table and headers in that template,i can bind the data set values to this template using vb

For Each myxmlnode In Travelerdoc.XMLNodes
If myxmlnode.BaseName = "WONumber" Then myxmlnode.Range.Text = ds.Tables(0).Rows(0).Item("wo").ToString()
If myxmlnode.BaseName = "CreatedDate" Then myxmlnode.Range.Text = Format(ds.Tables(0).Rows(0).Item("createddate"), Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern)
If myxmlnode.BaseName = "CompanyName" Then myxmlnode.Range.Text = CompanyName 'acct.Name
If myxmlnode.BaseName = "CompanyAddress" Then myxmlnode.Range.Text = CompanyAddress 'address.Address1
If myxmlnode.BaseName = "CompanyAddress1" Then myxmlnode.Range.Text = CompanyAddress1 'address.City & ", " & address.State & " " & address.ZipCode
If myxmlnode.BaseName = "Phone" Then myxmlnode.Range.Text = Phone 'acct.BusinessPhone
If myxmlnode.BaseName = "Fax" Then myxmlnode.Range.Text = Fax 'acct.BusinessFax
If myxmlnode.BaseName = "Email" Then myxmlnode.Range.Text = Email 'acct.Email
If myxmlnode.BaseName = "Item" Then myxmlnode.Range.Text = Item 'myCompItem.Name
If myxmlnode.BaseName = "ItemDesc" Then myxmlnode.Range.Text = ItemDesc 'myCompItem.Name
If myxmlnode.BaseName = "WOQty" Then myxmlnode.Range.Text = Format(ds.Tables(0).Rows(0).Item("quantity"), "#0.0000")
If myxmlnode.BaseName = "QtyComp" Then myxmlnode.Range.Text = CompQty
If myxmlnode.BaseName = "StartDate" Then myxmlnode.Range.Text = Format(ds.Tables(0).Rows(0).Item("startdate"), Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern)
If myxmlnode.BaseName = "DueDate" Then myxmlnode.Range.Text = Format(ds.Tables(0).Rows(0).Item("duedate"), Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern)
If myxmlnode.BaseName = "Status" Then myxmlnode.Range.Text = ds.Tables(0).Rows(0).Item("status").ToString()
If myxmlnode.BaseName = "Customer" Then myxmlnode.Range.Text = customer
If myxmlnode.BaseName = "SO" Then myxmlnode.Range.Text = salesorder​

And add the rows using

myxmlnode.Range.Select()
Travelerdoc.ActiveWindow.Selection.InsertRowsBelow()


but i have add one more row it showing error like There is no Row at position:3(actually in my dataset i have 3 rows).How can i solve this error please help me....
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top