Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Martin Martin is offline
external usenet poster
 
Posts: 3
Default Combining word documents in VB.NET

I am new to VB so be nice

I am trying to merge a number of word documents together, and am
trying to use the master/subdocument concept.

However, the documents are appearing at the top of the master
document, instead of being added sequentially at the end of the
document (which is what I want).

I have a template document which I wish to append these subdocuments
to. This template will contain a cover sheet, table of contents,
styles, headers/footers, etc etc.

The code I have is

Dim oDoc As Word.Document
Dim oPara As Word.Paragraph

oPara =
oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\ endofdoc").Range)
oPara.Range.Text = "Heading 1"
oPara.Range.InsertParagraphAfter()

oDoc.Application.ActiveDocument.Subdocuments.AddFr omFile("c:
\document1.doc")

oPara =
oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\ endofdoc").Range)
oPara.Range.Text = "Heading 2"
oPara.Range.InsertParagraphAfter()

oDoc.Application.ActiveDocument.Subdocuments.AddFr omFile("c:
\document2.doc")

However, the document generated looks like

c:\document1.doc ------ these are the hyperlinks to the subdocuments
c:\document2.doc

Template document stuff

Heading 1

Heading 2




I have tried making use of the endofdoc bookmark to try to get the
subdocuments at the end using the following:

oDoc.Application.ActiveDocument.Subdocuments.Expan ded = True
oDoc.Application.Selection.InsertParagraphAfter()
oDoc.Bookmarks.Item("\endofdoc").Range.Subdocument s.AddFromFile(vReports(vCount))

but this doesn't help either.

Can anyone please help me?

Thanks

Martin

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Martin Martin is offline
external usenet poster
 
Posts: 3
Default Combining word documents in VB.NET

I've got it resolved now. I added the following:

oDoc.Application.Selection.EndKey(Word.WdUnits.wdS tory)
oDoc.Application.ActiveDocument.Subdocuments.AddFr omFile("c:
\document1.doc")

This moves to the last page and adds the subdocument.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
combining documents jwb Microsoft Word Help 6 August 4th 07 02:30 AM
combining seperate word documents into one columbo Microsoft Word Help 1 July 17th 07 03:23 PM
Combining Documents Vicki_g Microsoft Word Help 2 July 11th 07 05:44 PM
Combining 5 documents to one Sunil Microsoft Word Help 3 December 7th 06 02:53 PM
Combining two Word documents Aixlachaise Microsoft Word Help 3 June 13th 06 11:24 PM


All times are GMT +1. The time now is 04:58 AM.

Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"