How to copy a word table multiple times to a specific place using VB.Net 2010?

I have viewed the other responses and these seem just not to work.

I am working on a VB.Net 2010 program using the Interop class.

We are having problems trying to duplicate a table more than 1 time to be put in the place we want.

It is either merging it with the original table in the Word Doc or putting it into the next table.

Is there a clear explanation on how a table can be duplicated 2-3 times?

It copies the first table fine but the 2nd is inserted into the table following the original table.

Imports Word = Microsoft.Office.Interop.Word
We are currently using functions as:

Rng = MyCopyFromRange
Rng.SetRange(MyCopyFromRange.End, MyCopyFromRange.End)

For MyCnt = 1 To pNoOf
WordApp.Selection.InsertAfter(MySepStr) ' not then it appends to the DevTable

WordApp.Selection.MoveDown() ' Move down needed if not appends to origina table

WordApp.Selection.Paste() ' Manual paste works without the move down this does not. It puts it in the next table

Recommended Answers

All 2 Replies

With Visual Basic I have had the same problem. May I suggest and I am not sure it will work but creating an array to store the data may solve your situation. It worked for me in a simular situation :-).

Have you thought of entering a blank line after you copy so that the next table would be in a separate paragraph?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.