Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Ricki Miles Ricki Miles is offline
external usenet poster
 
Posts: 50
Default Inserting many files into one document

I am working in Word 2003. I have over one thousand separate documents of
one or two pages of text each. There are no graphics, tables, etc. What is
the best way to combine them into a book consisting of one document? I
don't want to use Master Document as I know it has many problems. I am
thinking of using Insert File and making the formatting all the same. Any
other suggestions?

TIA

Ricki


  #2   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Inserting many files into one document

On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles" wrote:

I am working in Word 2003. I have over one thousand separate documents of
one or two pages of text each. There are no graphics, tables, etc. What is
the best way to combine them into a book consisting of one document? I
don't want to use Master Document as I know it has many problems. I am
thinking of using Insert File and making the formatting all the same. Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're already
thinking...

Do you want each inserted document to start on a new page? There are a couple of
ways to do that. The best, if each document starts with a heading formatted with
the same style, is to add "Page break before" paragraph formatting to the
definition of that style in the final document. The alternative is to insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in the order
that they should appear, then a macro could take that list as input and create
the consolidated document. (If the documents aren't all on one folder, the list
would have to include the full path to each one.) This would be a lot faster
than building it by hand.

If the documents were all based on the same template and use the same style
definitions, you shouldn't have any problems with formatting. If there could be
styles with the same names but different sets of properties in different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for the
considerations.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #3   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Ricki Miles Ricki Miles is offline
external usenet poster
 
Posts: 50
Default Inserting many files into one document

Thanks so much for your feedback. The documents should start on new pages
in the finished combined document, so your suggestion of "page break before"
for the heading style is perfect. I would like to create a macro that would
insert each documents in the order in which they appear in the folder, but I
don't know the VBA language to make it loop through. I'd appreciate help
with that coding. Thanks again,

Ricki

"Jay Freedman" wrote in message
...
On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles"
wrote:

I am working in Word 2003. I have over one thousand separate documents of
one or two pages of text each. There are no graphics, tables, etc. What
is
the best way to combine them into a book consisting of one document? I
don't want to use Master Document as I know it has many problems. I am
thinking of using Insert File and making the formatting all the same. Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're already
thinking...

Do you want each inserted document to start on a new page? There are a
couple of
ways to do that. The best, if each document starts with a heading
formatted with
the same style, is to add "Page break before" paragraph formatting to the
definition of that style in the final document. The alternative is to
insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in the
order
that they should appear, then a macro could take that list as input and
create
the consolidated document. (If the documents aren't all on one folder, the
list
would have to include the full path to each one.) This would be a lot
faster
than building it by hand.

If the documents were all based on the same template and use the same
style
definitions, you shouldn't have any problems with formatting. If there
could be
styles with the same names but different sets of properties in different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for the
considerations.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.



  #4   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Inserting many files into one document

Take a look at the article "Insert into a document the names of all files in
a selected folder" at:

http://www.word.mvps.org/FAQs/Macros...tFileNames.htm

and

"Print all documents in a given folder to a single print file" at:

http://www.word.mvps.org/FAQs/Macros...DocsInFldr.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Ricki Miles" wrote in message
...
Thanks so much for your feedback. The documents should start on new pages
in the finished combined document, so your suggestion of "page break
before" for the heading style is perfect. I would like to create a macro
that would insert each documents in the order in which they appear in the
folder, but I don't know the VBA language to make it loop through. I'd
appreciate help with that coding. Thanks again,

Ricki

"Jay Freedman" wrote in message
...
On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles"
wrote:

I am working in Word 2003. I have over one thousand separate documents
of
one or two pages of text each. There are no graphics, tables, etc. What
is
the best way to combine them into a book consisting of one document? I
don't want to use Master Document as I know it has many problems. I am
thinking of using Insert File and making the formatting all the same.
Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're already
thinking...

Do you want each inserted document to start on a new page? There are a
couple of
ways to do that. The best, if each document starts with a heading
formatted with
the same style, is to add "Page break before" paragraph formatting to the
definition of that style in the final document. The alternative is to
insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in the
order
that they should appear, then a macro could take that list as input and
create
the consolidated document. (If the documents aren't all on one folder,
the list
would have to include the full path to each one.) This would be a lot
faster
than building it by hand.

If the documents were all based on the same template and use the same
style
definitions, you shouldn't have any problems with formatting. If there
could be
styles with the same names but different sets of properties in different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for the
considerations.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.





  #5   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Ricki Miles Ricki Miles is offline
external usenet poster
 
Posts: 50
Default Inserting many files into one document

Thanks so much for the info!

Ricki

"Doug Robbins - Word MVP" wrote in message
...
Take a look at the article "Insert into a document the names of all files
in a selected folder" at:

http://www.word.mvps.org/FAQs/Macros...tFileNames.htm

and

"Print all documents in a given folder to a single print file" at:

http://www.word.mvps.org/FAQs/Macros...DocsInFldr.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Ricki Miles" wrote in message
...
Thanks so much for your feedback. The documents should start on new
pages in the finished combined document, so your suggestion of "page
break before" for the heading style is perfect. I would like to create a
macro that would insert each documents in the order in which they appear
in the folder, but I don't know the VBA language to make it loop through.
I'd appreciate help with that coding. Thanks again,

Ricki

"Jay Freedman" wrote in message
...
On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles"
wrote:

I am working in Word 2003. I have over one thousand separate documents
of
one or two pages of text each. There are no graphics, tables, etc.
What is
the best way to combine them into a book consisting of one document? I
don't want to use Master Document as I know it has many problems. I am
thinking of using Insert File and making the formatting all the same.
Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're already
thinking...

Do you want each inserted document to start on a new page? There are a
couple of
ways to do that. The best, if each document starts with a heading
formatted with
the same style, is to add "Page break before" paragraph formatting to
the
definition of that style in the final document. The alternative is to
insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in the
order
that they should appear, then a macro could take that list as input and
create
the consolidated document. (If the documents aren't all on one folder,
the list
would have to include the full path to each one.) This would be a lot
faster
than building it by hand.

If the documents were all based on the same template and use the same
style
definitions, you shouldn't have any problems with formatting. If there
could be
styles with the same names but different sets of properties in different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for the
considerations.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.









  #6   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Ricki Miles Ricki Miles is offline
external usenet poster
 
Posts: 50
Default Inserting many files into one document

Hi Doug,

I just tried using the macro in the article below - it inserts the filenames
into a document. What I need is the entire file text inserted into a
document, then the next one, etc. to build a new document with the text of
all the individual documents.

I'd appreciate some advice on how to create a macro to do this. Thanks
again,

Ricki

"Doug Robbins - Word MVP" wrote in message
...
Take a look at the article "Insert into a document the names of all files
in a selected folder" at:

http://www.word.mvps.org/FAQs/Macros...tFileNames.htm

and

"Print all documents in a given folder to a single print file" at:

http://www.word.mvps.org/FAQs/Macros...DocsInFldr.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Ricki Miles" wrote in message
...
Thanks so much for your feedback. The documents should start on new
pages in the finished combined document, so your suggestion of "page
break before" for the heading style is perfect. I would like to create a
macro that would insert each documents in the order in which they appear
in the folder, but I don't know the VBA language to make it loop through.
I'd appreciate help with that coding. Thanks again,

Ricki

"Jay Freedman" wrote in message
...
On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles"
wrote:

I am working in Word 2003. I have over one thousand separate documents
of
one or two pages of text each. There are no graphics, tables, etc.
What is
the best way to combine them into a book consisting of one document? I
don't want to use Master Document as I know it has many problems. I am
thinking of using Insert File and making the formatting all the same.
Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're already
thinking...

Do you want each inserted document to start on a new page? There are a
couple of
ways to do that. The best, if each document starts with a heading
formatted with
the same style, is to add "Page break before" paragraph formatting to
the
definition of that style in the final document. The alternative is to
insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in the
order
that they should appear, then a macro could take that list as input and
create
the consolidated document. (If the documents aren't all on one folder,
the list
would have to include the full path to each one.) This would be a lot
faster
than building it by hand.

If the documents were all based on the same template and use the same
style
definitions, you shouldn't have any problems with formatting. If there
could be
styles with the same names but different sets of properties in different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for the
considerations.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.







  #7   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Inserting many files into one document

Did you try the macro in the second article?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"Ricki Miles" wrote in message
...
Hi Doug,

I just tried using the macro in the article below - it inserts the
filenames into a document. What I need is the entire file text inserted
into a document, then the next one, etc. to build a new document with the
text of all the individual documents.

I'd appreciate some advice on how to create a macro to do this. Thanks
again,

Ricki

"Doug Robbins - Word MVP" wrote in message
...
Take a look at the article "Insert into a document the names of all files
in a selected folder" at:

http://www.word.mvps.org/FAQs/Macros...tFileNames.htm

and

"Print all documents in a given folder to a single print file" at:

http://www.word.mvps.org/FAQs/Macros...DocsInFldr.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Ricki Miles" wrote in message
...
Thanks so much for your feedback. The documents should start on new
pages in the finished combined document, so your suggestion of "page
break before" for the heading style is perfect. I would like to create
a macro that would insert each documents in the order in which they
appear in the folder, but I don't know the VBA language to make it loop
through. I'd appreciate help with that coding. Thanks again,

Ricki

"Jay Freedman" wrote in message
...
On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles"
wrote:

I am working in Word 2003. I have over one thousand separate documents
of
one or two pages of text each. There are no graphics, tables, etc.
What is
the best way to combine them into a book consisting of one document? I
don't want to use Master Document as I know it has many problems. I am
thinking of using Insert File and making the formatting all the same.
Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're already
thinking...

Do you want each inserted document to start on a new page? There are a
couple of
ways to do that. The best, if each document starts with a heading
formatted with
the same style, is to add "Page break before" paragraph formatting to
the
definition of that style in the final document. The alternative is to
insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in the
order
that they should appear, then a macro could take that list as input and
create
the consolidated document. (If the documents aren't all on one folder,
the list
would have to include the full path to each one.) This would be a lot
faster
than building it by hand.

If the documents were all based on the same template and use the same
style
definitions, you shouldn't have any problems with formatting. If there
could be
styles with the same names but different sets of properties in
different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for the
considerations.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.








  #8   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Inserting many files into one document

Suzanne, with apologies to you and Doug, the macro in the second article isn't
going to help Ricki very much -- it prints the documents to a .prn file. If all
you want is a printed copy of the combined document, then you can use the
instructions in http://askbobrankin.com/printing_a_prn_file.html to print the
..prn file. If you want an editable document, because you need to do formatting
such as setting the heading style to "Page break before", then this macro is
useless except as an example to someone who understands how to write and adapt a
macro.

The following macro takes the list of document names and compiles those
documents into one big document. You'll need to insert the real paths and file
names into the macro where indicated by the three "set this" comments. Before
you run this macro, read through the list of document names and make sure
they're in the order you want them to appear in the final document.

Sub CollectDocumentsIntoOne()
Dim DestDoc As Document
Dim SrcDoc As Document
Dim oRg As Range
Dim NamesFile As String
Dim DestName As String
Dim oPara As Paragraph
Dim MyPath As String
Dim MyName As String

' set this to the full path and name of the file
' that contains the list of document names:
NamesFile = "C:\SomeFolder\Includes.doc"

' set this to the path of the folder (with final backslash)
' that contains the files named in the list:
MyPath = "C:\SomeFolder\Letters\"

' set this to where you want the final document
' to be saved
DestName = "C:\SomeFolder\BigDoc.doc"

Set SrcDoc = Documents.Open(NamesFile)
Set DestDoc = Documents.Add
DestDoc.SaveAs FileName:=DestName

Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd

For Each oPara In SrcDoc.Paragraphs
If Len(oPara.Range.Text) 5 Then
' name must be at least one char plus ".doc¶"
MyName = oPara.Range.Text
MyName = Left$(MyName, Len(MyName) - 1)
On Error Resume Next
oRg.InsertFile FileName:=MyPath & MyName, _
ConfirmConversions:=False, Link:=False
If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If
End If
Next oPara

SrcDoc.Close SaveChanges:=wdDoNotSaveChanges

End Sub



On Sun, 24 Feb 2008 11:37:19 -0600, "Suzanne S. Barnhill"
wrote:

Did you try the macro in the second article?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"Ricki Miles" wrote in message
...
Hi Doug,

I just tried using the macro in the article below - it inserts the
filenames into a document. What I need is the entire file text inserted
into a document, then the next one, etc. to build a new document with the
text of all the individual documents.

I'd appreciate some advice on how to create a macro to do this. Thanks
again,

Ricki

"Doug Robbins - Word MVP" wrote in message
...
Take a look at the article "Insert into a document the names of all files
in a selected folder" at:

http://www.word.mvps.org/FAQs/Macros...tFileNames.htm

and

"Print all documents in a given folder to a single print file" at:

http://www.word.mvps.org/FAQs/Macros...DocsInFldr.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Ricki Miles" wrote in message
...
Thanks so much for your feedback. The documents should start on new
pages in the finished combined document, so your suggestion of "page
break before" for the heading style is perfect. I would like to create
a macro that would insert each documents in the order in which they
appear in the folder, but I don't know the VBA language to make it loop
through. I'd appreciate help with that coding. Thanks again,

Ricki

"Jay Freedman" wrote in message
...
On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles"
wrote:

I am working in Word 2003. I have over one thousand separate documents
of
one or two pages of text each. There are no graphics, tables, etc.
What is
the best way to combine them into a book consisting of one document? I
don't want to use Master Document as I know it has many problems. I am
thinking of using Insert File and making the formatting all the same.
Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're already
thinking...

Do you want each inserted document to start on a new page? There are a
couple of
ways to do that. The best, if each document starts with a heading
formatted with
the same style, is to add "Page break before" paragraph formatting to
the
definition of that style in the final document. The alternative is to
insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in the
order
that they should appear, then a macro could take that list as input and
create
the consolidated document. (If the documents aren't all on one folder,
the list
would have to include the full path to each one.) This would be a lot
faster
than building it by hand.

If the documents were all based on the same template and use the same
style
definitions, you shouldn't have any problems with formatting. If there
could be
styles with the same names but different sets of properties in
different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for the
considerations.


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #9   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Ricki Miles Ricki Miles is offline
external usenet poster
 
Posts: 50
Default Inserting many files into one document


Thanks, Jay,

I tried the macro below and it works perfectly.

I do, however, have all the files in the correct order in a folder. Is it
possible to run a macro that loops through the filenames in the folder and
inserts them, rather than using the method below where you need the
filenames in an actual file?

Thanks again - much appreciated,

Ricki

"Jay Freedman" wrote in message
...
Suzanne, with apologies to you and Doug, the macro in the second article
isn't
going to help Ricki very much -- it prints the documents to a .prn file.
If all
you want is a printed copy of the combined document, then you can use the
instructions in http://askbobrankin.com/printing_a_prn_file.html to print
the
.prn file. If you want an editable document, because you need to do
formatting
such as setting the heading style to "Page break before", then this macro
is
useless except as an example to someone who understands how to write and
adapt a
macro.

The following macro takes the list of document names and compiles those
documents into one big document. You'll need to insert the real paths and
file
names into the macro where indicated by the three "set this" comments.
Before
you run this macro, read through the list of document names and make sure
they're in the order you want them to appear in the final document.

Sub CollectDocumentsIntoOne()
Dim DestDoc As Document
Dim SrcDoc As Document
Dim oRg As Range
Dim NamesFile As String
Dim DestName As String
Dim oPara As Paragraph
Dim MyPath As String
Dim MyName As String

' set this to the full path and name of the file
' that contains the list of document names:
NamesFile = "C:\SomeFolder\Includes.doc"

' set this to the path of the folder (with final backslash)
' that contains the files named in the list:
MyPath = "C:\SomeFolder\Letters\"

' set this to where you want the final document
' to be saved
DestName = "C:\SomeFolder\BigDoc.doc"

Set SrcDoc = Documents.Open(NamesFile)
Set DestDoc = Documents.Add
DestDoc.SaveAs FileName:=DestName

Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd

For Each oPara In SrcDoc.Paragraphs
If Len(oPara.Range.Text) 5 Then
' name must be at least one char plus ".doc¶"
MyName = oPara.Range.Text
MyName = Left$(MyName, Len(MyName) - 1)
On Error Resume Next
oRg.InsertFile FileName:=MyPath & MyName, _
ConfirmConversions:=False, Link:=False
If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If
End If
Next oPara

SrcDoc.Close SaveChanges:=wdDoNotSaveChanges

End Sub



On Sun, 24 Feb 2008 11:37:19 -0600, "Suzanne S. Barnhill"

wrote:

Did you try the macro in the second article?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"Ricki Miles" wrote in message
...
Hi Doug,

I just tried using the macro in the article below - it inserts the
filenames into a document. What I need is the entire file text inserted
into a document, then the next one, etc. to build a new document with
the
text of all the individual documents.

I'd appreciate some advice on how to create a macro to do this. Thanks
again,

Ricki

"Doug Robbins - Word MVP" wrote in message
...
Take a look at the article "Insert into a document the names of all
files
in a selected folder" at:

http://www.word.mvps.org/FAQs/Macros...tFileNames.htm

and

"Print all documents in a given folder to a single print file" at:

http://www.word.mvps.org/FAQs/Macros...DocsInFldr.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Ricki Miles" wrote in message
...
Thanks so much for your feedback. The documents should start on new
pages in the finished combined document, so your suggestion of "page
break before" for the heading style is perfect. I would like to
create
a macro that would insert each documents in the order in which they
appear in the folder, but I don't know the VBA language to make it
loop
through. I'd appreciate help with that coding. Thanks again,

Ricki

"Jay Freedman" wrote in message
...
On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles"

wrote:

I am working in Word 2003. I have over one thousand separate
documents
of
one or two pages of text each. There are no graphics, tables, etc.
What is
the best way to combine them into a book consisting of one document?
I
don't want to use Master Document as I know it has many problems. I
am
thinking of using Insert File and making the formatting all the same.
Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're already
thinking...

Do you want each inserted document to start on a new page? There are
a
couple of
ways to do that. The best, if each document starts with a heading
formatted with
the same style, is to add "Page break before" paragraph formatting to
the
definition of that style in the final document. The alternative is to
insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in
the
order
that they should appear, then a macro could take that list as input
and
create
the consolidated document. (If the documents aren't all on one
folder,
the list
would have to include the full path to each one.) This would be a lot
faster
than building it by hand.

If the documents were all based on the same template and use the same
style
definitions, you shouldn't have any problems with formatting. If
there
could be
styles with the same names but different sets of properties in
different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for
the
considerations.


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.



  #10   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Inserting many files into one document

Yes, that's not hard. The idea is to combine the macro that lists the files with
the macro that puts them together:

Sub CollectDocumentsIntoOne()
Dim DestDoc As Document
Dim oRg As Range
Dim MyPath As String
Dim MyName As String

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

Set DestDoc = Documents.Add
DestDoc.Save ' pop up SaveAs dialog

Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.doc")
Do While MyName ""
On Error Resume Next
oRg.InsertFile FileName:=MyPath & MyName, _
ConfirmConversions:=False, Link:=False
If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If
MyName = Dir
Loop

End Sub

This time you don't have to set up any file names or paths in the macro. The
first dialog that appears when you run the macro (with the title "Copy",
unfortunately) lets you choose the folder containing the documents. Then a
second dialog ("Save As") lets you choose a folder and file name for the
combined document.


On Sun, 24 Feb 2008 16:02:28 -0600, "Ricki Miles" wrote:
Thanks, Jay,

I tried the macro below and it works perfectly.

I do, however, have all the files in the correct order in a folder. Is it
possible to run a macro that loops through the filenames in the folder and
inserts them, rather than using the method below where you need the
filenames in an actual file?

Thanks again - much appreciated,

Ricki

"Jay Freedman" wrote in message
.. .
Suzanne, with apologies to you and Doug, the macro in the second article
isn't
going to help Ricki very much -- it prints the documents to a .prn file.
If all
you want is a printed copy of the combined document, then you can use the
instructions in http://askbobrankin.com/printing_a_prn_file.html to print
the
.prn file. If you want an editable document, because you need to do
formatting
such as setting the heading style to "Page break before", then this macro
is
useless except as an example to someone who understands how to write and
adapt a
macro.

The following macro takes the list of document names and compiles those
documents into one big document. You'll need to insert the real paths and
file
names into the macro where indicated by the three "set this" comments.
Before
you run this macro, read through the list of document names and make sure
they're in the order you want them to appear in the final document.

Sub CollectDocumentsIntoOne()
Dim DestDoc As Document
Dim SrcDoc As Document
Dim oRg As Range
Dim NamesFile As String
Dim DestName As String
Dim oPara As Paragraph
Dim MyPath As String
Dim MyName As String

' set this to the full path and name of the file
' that contains the list of document names:
NamesFile = "C:\SomeFolder\Includes.doc"

' set this to the path of the folder (with final backslash)
' that contains the files named in the list:
MyPath = "C:\SomeFolder\Letters\"

' set this to where you want the final document
' to be saved
DestName = "C:\SomeFolder\BigDoc.doc"

Set SrcDoc = Documents.Open(NamesFile)
Set DestDoc = Documents.Add
DestDoc.SaveAs FileName:=DestName

Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd

For Each oPara In SrcDoc.Paragraphs
If Len(oPara.Range.Text) 5 Then
' name must be at least one char plus ".doc¶"
MyName = oPara.Range.Text
MyName = Left$(MyName, Len(MyName) - 1)
On Error Resume Next
oRg.InsertFile FileName:=MyPath & MyName, _
ConfirmConversions:=False, Link:=False
If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If
End If
Next oPara

SrcDoc.Close SaveChanges:=wdDoNotSaveChanges

End Sub



On Sun, 24 Feb 2008 11:37:19 -0600, "Suzanne S. Barnhill"

wrote:

Did you try the macro in the second article?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"Ricki Miles" wrote in message
...
Hi Doug,

I just tried using the macro in the article below - it inserts the
filenames into a document. What I need is the entire file text inserted
into a document, then the next one, etc. to build a new document with
the
text of all the individual documents.

I'd appreciate some advice on how to create a macro to do this. Thanks
again,

Ricki

"Doug Robbins - Word MVP" wrote in message
...
Take a look at the article "Insert into a document the names of all
files
in a selected folder" at:

http://www.word.mvps.org/FAQs/Macros...tFileNames.htm

and

"Print all documents in a given folder to a single print file" at:

http://www.word.mvps.org/FAQs/Macros...DocsInFldr.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Ricki Miles" wrote in message
...
Thanks so much for your feedback. The documents should start on new
pages in the finished combined document, so your suggestion of "page
break before" for the heading style is perfect. I would like to
create
a macro that would insert each documents in the order in which they
appear in the folder, but I don't know the VBA language to make it
loop
through. I'd appreciate help with that coding. Thanks again,

Ricki

"Jay Freedman" wrote in message
...
On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles"

wrote:

I am working in Word 2003. I have over one thousand separate
documents
of
one or two pages of text each. There are no graphics, tables, etc.
What is
the best way to combine them into a book consisting of one document?
I
don't want to use Master Document as I know it has many problems. I
am
thinking of using Insert File and making the formatting all the same.
Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're already
thinking...

Do you want each inserted document to start on a new page? There are
a
couple of
ways to do that. The best, if each document starts with a heading
formatted with
the same style, is to add "Page break before" paragraph formatting to
the
definition of that style in the final document. The alternative is to
insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in
the
order
that they should appear, then a macro could take that list as input
and
create
the consolidated document. (If the documents aren't all on one
folder,
the list
would have to include the full path to each one.) This would be a lot
faster
than building it by hand.

If the documents were all based on the same template and use the same
style
definitions, you shouldn't have any problems with formatting. If
there
could be
styles with the same names but different sets of properties in
different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for
the
considerations.


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.


  #11   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Ricki Miles Ricki Miles is offline
external usenet poster
 
Posts: 50
Default Inserting many files into one document

Jay, thank you so much for the information. I tried it and it works
perfectly. Where would I put in code for a hard page break between each
document?

Thanks again,

Ricki

"Jay Freedman" wrote in message
...
Yes, that's not hard. The idea is to combine the macro that lists the
files with
the macro that puts them together:

Sub CollectDocumentsIntoOne()
Dim DestDoc As Document
Dim oRg As Range
Dim MyPath As String
Dim MyName As String

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

Set DestDoc = Documents.Add
DestDoc.Save ' pop up SaveAs dialog

Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.doc")
Do While MyName ""
On Error Resume Next
oRg.InsertFile FileName:=MyPath & MyName, _
ConfirmConversions:=False, Link:=False
If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If
MyName = Dir
Loop

End Sub

This time you don't have to set up any file names or paths in the macro.
The
first dialog that appears when you run the macro (with the title "Copy",
unfortunately) lets you choose the folder containing the documents. Then a
second dialog ("Save As") lets you choose a folder and file name for the
combined document.


On Sun, 24 Feb 2008 16:02:28 -0600, "Ricki Miles"
wrote:
Thanks, Jay,

I tried the macro below and it works perfectly.

I do, however, have all the files in the correct order in a folder. Is it
possible to run a macro that loops through the filenames in the folder and
inserts them, rather than using the method below where you need the
filenames in an actual file?

Thanks again - much appreciated,

Ricki

"Jay Freedman" wrote in message
. ..
Suzanne, with apologies to you and Doug, the macro in the second article
isn't
going to help Ricki very much -- it prints the documents to a .prn file.
If all
you want is a printed copy of the combined document, then you can use
the
instructions in http://askbobrankin.com/printing_a_prn_file.html to
print
the
.prn file. If you want an editable document, because you need to do
formatting
such as setting the heading style to "Page break before", then this
macro
is
useless except as an example to someone who understands how to write and
adapt a
macro.

The following macro takes the list of document names and compiles those
documents into one big document. You'll need to insert the real paths
and
file
names into the macro where indicated by the three "set this" comments.
Before
you run this macro, read through the list of document names and make
sure
they're in the order you want them to appear in the final document.

Sub CollectDocumentsIntoOne()
Dim DestDoc As Document
Dim SrcDoc As Document
Dim oRg As Range
Dim NamesFile As String
Dim DestName As String
Dim oPara As Paragraph
Dim MyPath As String
Dim MyName As String

' set this to the full path and name of the file
' that contains the list of document names:
NamesFile = "C:\SomeFolder\Includes.doc"

' set this to the path of the folder (with final backslash)
' that contains the files named in the list:
MyPath = "C:\SomeFolder\Letters\"

' set this to where you want the final document
' to be saved
DestName = "C:\SomeFolder\BigDoc.doc"

Set SrcDoc = Documents.Open(NamesFile)
Set DestDoc = Documents.Add
DestDoc.SaveAs FileName:=DestName

Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd

For Each oPara In SrcDoc.Paragraphs
If Len(oPara.Range.Text) 5 Then
' name must be at least one char plus ".doc¶"
MyName = oPara.Range.Text
MyName = Left$(MyName, Len(MyName) - 1)
On Error Resume Next
oRg.InsertFile FileName:=MyPath & MyName, _
ConfirmConversions:=False, Link:=False
If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If
End If
Next oPara

SrcDoc.Close SaveChanges:=wdDoNotSaveChanges

End Sub



On Sun, 24 Feb 2008 11:37:19 -0600, "Suzanne S. Barnhill"

wrote:

Did you try the macro in the second article?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"Ricki Miles" wrote in message
.. .
Hi Doug,

I just tried using the macro in the article below - it inserts the
filenames into a document. What I need is the entire file text
inserted
into a document, then the next one, etc. to build a new document with
the
text of all the individual documents.

I'd appreciate some advice on how to create a macro to do this.
Thanks
again,

Ricki

"Doug Robbins - Word MVP" wrote in message
...
Take a look at the article "Insert into a document the names of all
files
in a selected folder" at:

http://www.word.mvps.org/FAQs/Macros...tFileNames.htm

and

"Print all documents in a given folder to a single print file" at:

http://www.word.mvps.org/FAQs/Macros...DocsInFldr.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Ricki Miles" wrote in message
...
Thanks so much for your feedback. The documents should start on new
pages in the finished combined document, so your suggestion of "page
break before" for the heading style is perfect. I would like to
create
a macro that would insert each documents in the order in which they
appear in the folder, but I don't know the VBA language to make it
loop
through. I'd appreciate help with that coding. Thanks again,

Ricki

"Jay Freedman" wrote in message
...
On Sat, 23 Feb 2008 12:33:45 -0600, "Ricki Miles"

wrote:

I am working in Word 2003. I have over one thousand separate
documents
of
one or two pages of text each. There are no graphics, tables, etc.
What is
the best way to combine them into a book consisting of one
document?
I
don't want to use Master Document as I know it has many problems.
I
am
thinking of using Insert File and making the formatting all the
same.
Any
other suggestions?

TIA

Ricki


Not really a separate suggestion, but building on what you're
already
thinking...

Do you want each inserted document to start on a new page? There
are
a
couple of
ways to do that. The best, if each document starts with a heading
formatted with
the same style, is to add "Page break before" paragraph formatting
to
the
definition of that style in the final document. The alternative is
to
insert a
New Page section break between documents as you add them.

If you have a list of the file names of the separate documents, in
the
order
that they should appear, then a macro could take that list as input
and
create
the consolidated document. (If the documents aren't all on one
folder,
the list
would have to include the full path to each one.) This would be a
lot
faster
than building it by hand.

If the documents were all based on the same template and use the
same
style
definitions, you shouldn't have any problems with formatting. If
there
could be
styles with the same names but different sets of properties in
different
documents, though, you may run into trouble. See
http://www.shaunakelly.com/word/styl...xtChanges.html for
the
considerations.


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.



  #12   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Inserting many files into one document

Somewhere early in the thread we discussed adding "Page break before" to the
paragraph formatting of the heading that starts each page. That's much the
easiest way.

If the pages don't all start with a heading with the same style, then you can
make the macro insert a page break, although that's less reliable (for example,
if the page before the break comes to the bottom of the page, the page break
will cause a blank page). Replace the lines

If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If

with

If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
oRg.InsertBreak Type:=wdPageBreak
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If

One more thing: This will leave a page break and a blank page at the end of the
last included document, which you should delete if you plan to print the
combined document.


On Mon, 25 Feb 2008 17:58:28 -0600, "Ricki Miles" wrote:

Jay, thank you so much for the information. I tried it and it works
perfectly. Where would I put in code for a hard page break between each
document?

Thanks again,

Ricki

"Jay Freedman" wrote in message
.. .
Yes, that's not hard. The idea is to combine the macro that lists the
files with
the macro that puts them together:

Sub CollectDocumentsIntoOne()
Dim DestDoc As Document
Dim oRg As Range
Dim MyPath As String
Dim MyName As String

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

Set DestDoc = Documents.Add
DestDoc.Save ' pop up SaveAs dialog

Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.doc")
Do While MyName ""
On Error Resume Next
oRg.InsertFile FileName:=MyPath & MyName, _
ConfirmConversions:=False, Link:=False
If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If
MyName = Dir
Loop

End Sub

This time you don't have to set up any file names or paths in the macro.
The
first dialog that appears when you run the macro (with the title "Copy",
unfortunately) lets you choose the folder containing the documents. Then a
second dialog ("Save As") lets you choose a folder and file name for the
combined document.


On Sun, 24 Feb 2008 16:02:28 -0600, "Ricki Miles"
wrote:
Thanks, Jay,

I tried the macro below and it works perfectly.

I do, however, have all the files in the correct order in a folder. Is it
possible to run a macro that loops through the filenames in the folder and
inserts them, rather than using the method below where you need the
filenames in an actual file?

Thanks again - much appreciated,

Ricki


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #13   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Ricki Miles Ricki Miles is offline
external usenet poster
 
Posts: 50
Default Inserting many files into one document

Thanks again for all the information,

Ricki

"Jay Freedman" wrote in message
...
Somewhere early in the thread we discussed adding "Page break before" to
the
paragraph formatting of the heading that starts each page. That's much the
easiest way.

If the pages don't all start with a heading with the same style, then you
can
make the macro insert a page break, although that's less reliable (for
example,
if the page before the break comes to the bottom of the page, the page
break
will cause a blank page). Replace the lines

If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If

with

If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
oRg.InsertBreak Type:=wdPageBreak
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If

One more thing: This will leave a page break and a blank page at the end
of the
last included document, which you should delete if you plan to print the
combined document.


On Mon, 25 Feb 2008 17:58:28 -0600, "Ricki Miles"
wrote:

Jay, thank you so much for the information. I tried it and it works
perfectly. Where would I put in code for a hard page break between each
document?

Thanks again,

Ricki

"Jay Freedman" wrote in message
. ..
Yes, that's not hard. The idea is to combine the macro that lists the
files with
the macro that puts them together:

Sub CollectDocumentsIntoOne()
Dim DestDoc As Document
Dim oRg As Range
Dim MyPath As String
Dim MyName As String

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

Set DestDoc = Documents.Add
DestDoc.Save ' pop up SaveAs dialog

Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.doc")
Do While MyName ""
On Error Resume Next
oRg.InsertFile FileName:=MyPath & MyName, _
ConfirmConversions:=False, Link:=False
If Err.Number = 0 Then
DestDoc.Save
Set oRg = DestDoc.Range
oRg.Collapse wdCollapseEnd
End If
MyName = Dir
Loop

End Sub

This time you don't have to set up any file names or paths in the macro.
The
first dialog that appears when you run the macro (with the title "Copy",
unfortunately) lets you choose the folder containing the documents. Then
a
second dialog ("Save As") lets you choose a folder and file name for the
combined document.


On Sun, 24 Feb 2008 16:02:28 -0600, "Ricki Miles"
wrote:
Thanks, Jay,

I tried the macro below and it works perfectly.

I do, however, have all the files in the correct order in a folder. Is
it
possible to run a macro that loops through the filenames in the folder
and
inserts them, rather than using the method below where you need the
filenames in an actual file?

Thanks again - much appreciated,

Ricki


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.



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
inserting files into word document McMillion Microsoft Word Help 1 May 4th 07 04:58 AM
Inserting multiple files mfayaz Microsoft Word Help 1 July 11th 06 02:51 PM
inserting files into a main document? talderman Microsoft Word Help 1 May 15th 06 06:51 PM
inserting pdf files in Word Georgea Microsoft Word Help 3 January 23rd 06 03:20 PM
Inserting Files as objects into Forms Protected Word document Ravi Nookala Microsoft Word Help 2 May 26th 05 05:39 AM


All times are GMT +1. The time now is 11:23 AM.

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

About Us

"It's about Microsoft Word"