Copy contents from one Word doc to another(tables, OLE objs, text)

U

UnkName

Scenario:
VB or C# .NET
Microsoft Office Automation
using also automation we're obtaining the source documents from another
application and these documents have to be 'merged' into a single one

I need to be able to append content from many source documents to a
'destination' document using Office automation. The source documents contain
quite complex content (a table and an OLE object) and what is basically
needed is that everything in the source document must exist in the
destination one. The source documents are generated starting from a common
template (it's not really a template but rather a skeleton document where
some fields are filled and some custom OLE object is edited) - in case this
helps.

Any hint would be very useful: what object/method in the Office object model
to use ... anything.


Please advise.
Thanks a lot
 
U

UnkName

Seems like I've found the solution:

- open an empty document using the same template as those that are about to
be linked
- select the document
- rWordApplicationInstance.Selection.Collapse(
Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd) (x)
- rWordApplicationInstance.Selection.InsertFile("<path to the already saved
file that must pe concatenated>")
- (optional) rWordApplicationInstance.Selection.InsertBreak(
Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak)
- repeat from (x) for each document that you want to insert

It worked for me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top