Doug
Tue Mar 13 07:45:30 CDT 2007
Use the following:
Dim MyPath As String
Dim MyName As String
Dim Mydoc As Document, NewDoc As Document
Dim docrange As Range
'Create a new document
Set NewDoc = Documents.Add
'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
'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName <> ""
Set Mydoc = Documents.Open(MyName)
Set docrange = Mydoc.Range
NewDoc.Range.InsertAfter docrange.FormattedText
Mydoc.Close wdDoNotSaveChanges
MyName = Dir
Loop
'NewDoc should now contain all of the other documents
--
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
<emailtoalex@gmail.com> wrote in message
news:1173740888.354932.309580@30g2000cwc.googlegroups.com...
> Hi,
>
> I have hundreds of half-page documents (each of them has only a few
> lines) and I would like to combine them, one immediately after
> another, so that I can print the combined document out without a lot
> of white space.
>
> I have searched and found this VBA code:
>
>
http://word.mvps.org/FAQs/MacrosVBA/PrintAllDocsInFldr.htm
>
> However it prints each document individually and the result is a waste
> of paper because each file only has a few lines in it.
>
> Thanks!
>
> Alex
>