Append Documents

B

ben

I am trying to appending word documents that are in memory, that are not on
the file system. I have seen the examples of appending multiple files that
reside on the file system, but that is not what I am trying to do. I will
receive a collection of word files and I need to append them together into a
master document without having to write each one to the file system. The
other issue that I will have is that each document will have different
headers and footers. Can this been doen without too much hassel?

Thanks for any input
 
J

Jean-Guy Marcil

ben was telling us:
ben nous racontait que :
I am trying to appending word documents that are in memory, that are
not on the file system. I have seen the examples of appending

??? Don't get this part...
multiple files that reside on the file system, but that is not what I
am trying to do. I will receive a collection of word files and I

When you receive them, they are in the file system, no? If not, where else
can they be?
need to append them together into a master document without having to
write each one to the file system. The other issue that I will have
is that each document will have different headers and footers. Can
this been doen without too much hassel?

Generally, what you do is:

Create a document,
Insert the first document,
Insert a section Break- Next page,
Insert the next document,
and so on.

There are however many issues.

Page numbering may get out of whack, depending on how it is defined in each
document.
List numbering will certainly get all out of whack.
Styles may be modified, thus page content / text formatting may change if
style definitions are changed (If Style A in Document A is set to double
line spacing, but Style A in Document B is set to Single line spacing,
something has got to give somewhere).

This usually works well only if all documents were created from controlled
templates and that styles were used appropriately.
Otherwise, a real can of worms...

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

ben

Let me start over. I was trying to over simplify the issue.

I have word 30 word documents on a file system. A user will determine which
of the 30 documents he / she wants to populate / print. So one process could
be using 5 documents and another job could be using 10 documents.

I load one document into memory, I populate fields in the document, then I
need to append the document to a master document. I move to the second
document, open the document, populate the fields in the document, then append
the document to the master document. So the example posted previously in
this group will not work for me because it appends a document that is on the
file system. Hope this makes sense.
 
J

Jean-Guy Marcil

ben was telling us:
ben nous racontait que :
Let me start over. I was trying to over simplify the issue.

I have word 30 word documents on a file system. A user will
determine which of the 30 documents he / she wants to populate /
print. So one process could be using 5 documents and another job
could be using 10 documents.

I load one document into memory, I populate fields in the document,
then I need to append the document to a master document. I move to
the second document, open the document, populate the fields in the
document, then append the document to the master document. So the
example posted previously in this group will not work for me because
it appends a document that is on the file system. Hope this makes
sense.

Can't you just transfer the content of the opened temp document (after
updating the fields) to the opened master document, then close the temp
document, open the next one, and so on.

With which part of this processes are you having difficulties?

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

ben

So ist he only way to do what I want is to strip the content out of a
document and insert the content into another document? If so, I am assuming
that I have to do each heard, footer, and main text range one at a time. is
this true? do you have an example of how to do this?

sorry for being a little slow, but this is my first word development task.
 
D

David Sisson

So is the only way to do what I want ..

No, but...

Just as Jean-Guy stated, if the styles are different, it really can
throw your document into chaos.

Having said that, you can...

Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.InsertFile FileName:= _
"C:\My Documents\" & Selected_Array(Counter), Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False

Of course, you'll have to built a userform to list the files (probably
in a listbox) so users can pick the files they want. Then loop through
the selected list, adding the files with the above code. (It probably
would work better with Range instead of Selection, but one thing at a
time.)
 

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