I loaded a macro that sounded promising, that would print all documents in a
folder to a file. Wonderful. Now, how do you choose a folder to print it? I
can choose documents, but have no idea how to choose a folder.
Jean-Guy Marcil - 30 Aug 2006 21:00 GMT
jknapp1005 was telling us:
jknapp1005 nous racontait que :
> I loaded a macro that sounded promising, that would print all
> documents in a folder to a file. Wonderful. Now, how do you choose a
> folder to print it? I can choose documents, but have no idea how to
> choose a folder.
What macro are you referring to?

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Doug Robbins - Word MVP - 30 Aug 2006 21:10 GMT
See how it is done in the following that I posted in response to another
question further down this newsgroup:
Dim MyPath As String
Dim MyName As String
Dim Source As Document, Target As Document
Dim SourceFile As Range
Dim i As Long
Dim FileList As Document
Set FileList = 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 <> ""
Selection.InsertAfter MyName & vbCr
MyName = Dir
Loop
'Sort the list of files
FileList.Range.Sort SortFieldType:=wdSortFieldAlphanumeric,
FieldNumber:="Paragraphs"
'Delete the empty paragraph that will be at the top of the list of files
FileList.Paragraphs(1).Range.Delete
'Start a new document into which each of the others will be inserted
Set Target = Documents.Add
'Iterate through the list of files, getting the name of each file, opening
it
'and inserting its contents into the Target document
For i = 1 To FileList.Paragraphs.Count
Set SourceFile = FileList.Paragraphs(i).Range
SourceFile.End = SourceFile.End - 1
Set Source = Documents.Open(MyPath & SourceFile.Text)
Target.Range.InsertAfter Source.Range.FormattedText
Source.Close wdDoNotSaveChanges
Next i
Also see the article "Print all documents in a given folder to a single
print file" at:
http://www.word.mvps.org/FAQs/MacrosVBA/PrintAllDocsInFldr.htm

Signature
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
>I loaded a macro that sounded promising, that would print all documents in
>a
> folder to a file. Wonderful. Now, how do you choose a folder to print it?
> I
> can choose documents, but have no idea how to choose a folder.