merging docs in on doc

J

Jesper F

I'm automating Word from Acces and sending data into different templates
with bookmarks for the data.
Would it be possible to merge the content of for example 5 open Word
documents consecutively into a 6th document?
Thanks for any input.

Jesper, Denmark
 
J

Jean-Guy Marcil

Jesper F was telling us:
Jesper F nous racontait que :
I'm automating Word from Acces and sending data into different
templates with bookmarks for the data.
Would it be possible to merge the content of for example 5 open Word
documents consecutively into a 6th document?
Thanks for any input.

Yes, but how about headers/footers and styles? Are they different from
document to document? Do you need to preserve them, or just the text is
important?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jesper F

I'm automating Word from Acces and sending data into different
Yes, but how about headers/footers and styles? Are they different from
document to document? Do you need to preserve them, or just the text is
important?

No I just need the text and a few tables moved to the main document. There
are no header and footer styles.
I guess what I'm after is a situation with 5 very short documents with a
small table in each and nothing else.
I'd like have the content (these tables) copied to the main document.

Alternatively, I could have one large document with all my specially layed
out tables as a form of "repository", say 40-50 tables in this on large
document.
And then through code pick out some of these tables (identifiable through
numbering or bookmarks) and copy these to the main document. The
"child"-document(s) don't need to be visible, only the main document.
I realize this is a strange setup, but I guess I just need to know how to
copy a chunk of content to another document.
Thanks for any input or thoughts.


Jesper
 
J

Jean-Guy Marcil

Jesper F was telling us:
Jesper F nous racontait que :
No I just need the text and a few tables moved to the main document.
There are no header and footer styles.
I guess what I'm after is a situation with 5 very short documents
with a small table in each and nothing else.
I'd like have the content (these tables) copied to the main document.

Alternatively, I could have one large document with all my specially
layed out tables as a form of "repository", say 40-50 tables in this
on large document.
And then through code pick out some of these tables (identifiable
through numbering or bookmarks) and copy these to the main document.
The "child"-document(s) don't need to be visible, only the main
document.
I realize this is a strange setup, but I guess I just need to know
how to copy a chunk of content to another document.
Thanks for any input or thoughts.

Here is some sample code you can use to get you started:

'_______________________________________
Dim masterDoc As Document
Dim childDoc As Document
Dim masterDocRge As Range
Dim childDocRge As Range

Set masterDoc = ActiveDocument

Set masterDocRge = masterDoc.Range

'Start some sort of loop to cycle your child documents
Set childDoc = Documents.Open("mypath\Some Document.doc")
Set childDocRge = childDoc.Range.FormattedText
'To remove last ¶ from range to transfer
childDocRge.MoveEnd wdCharacter, -1
With masterDocRge
.Collapse wdCollapseEnd
.FormattedText = childDocRge
.Collapse wdCollapseEnd
'To prevent all ranges to be continuous
.InsertParagraphAfter
End With
childDoc.Close wdDoNotSaveChanges
'Next or Wend or Loop
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jesper F

I'm automating Word from Acces and sending data into different
Here is some sample code you can use to get you started:

'_______________________________________
Dim masterDoc As Document
Dim childDoc As Document
Dim masterDocRge As Range
Dim childDocRge As Range

Set masterDoc = ActiveDocument

Set masterDocRge = masterDoc.Range

'Start some sort of loop to cycle your child documents
Set childDoc = Documents.Open("mypath\Some Document.doc")
Set childDocRge = childDoc.Range.FormattedText
'To remove last ¶ from range to transfer
childDocRge.MoveEnd wdCharacter, -1
With masterDocRge
.Collapse wdCollapseEnd
.FormattedText = childDocRge
.Collapse wdCollapseEnd
'To prevent all ranges to be continuous
.InsertParagraphAfter
End With
childDoc.Close wdDoNotSaveChanges
'Next or Wend or Loop
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org


Merci beaucoup! :)
 

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