Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Print all docs in folder macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jknapp1005 - 30 Aug 2006 17:46 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.