Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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.



 
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 10:47 PM.

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"