View Full Version : Solved: printing a document in order specified
Hi Experts
Is it possible to print a document in order via a macro button within a word document?
i have a folder called part 1 and part 2 within the shared directory and i want to set the order of the word documents and power point documents within the two folders so it prints in the order i specify.
both folder are in the y:\ drive
fumei
09-17-2008, 10:26 AM
I am confused.
What do you mean by "a document in order"? I do not understand " i want to set the order of the word documents and power point documents within the two folders so it prints in the order i specify."
Set the order? OK, then specify the order - perhaps by listing them in an array - and then print them.
Dim MyPrintList()
Dim j As Long
MyPrintList = Array("Y:\Part 1\firstdoc.doc", _
"Y:\Part 1\seconddoc", _
"Y:\Part 2\thirddoc.", _
"Y:\Part 1\fourthdoc.doc", _
"Y:\Part 2\fifthdoc.doc")
For j = 0 To UBound(MyPrintList)
Documents.Open FileName:=What(j)
ActiveDocument.PrintOut ' plus whatever parameters you need
ActiveDocument.Close wdDoNotSaveChanges
Next
I have to ask WHY the order is important.
saves me going into each doucment one by one and printing them..........
By doucments i mean in each folder there are numerius word files, that i would like to print in the order i want to via a mcaro as opposed to clicking and opening them one by one.....
fumei
09-17-2008, 01:12 PM
If you doing it IN Word, then you must open them to print.
The code I posted will open and print all files specified in the array. That is, it will print the files "in the order I want". Which is what you are asking for.
That is why I asked about WHY the order is important...a question you did not answer.
If you just wanted to print all the doc files in a given folder, then:
Dim file
Dim path As String
path = "c:\zzz\yadda\"
file = Dir(path & "*.doc")
Do While file <> ""
Documents.Open file
With ActiveDocument
.PrintOut ' with any parameters
.Close
End With
file = Dir
Loop
will open and print all .doc files in "c:\zzz\yadda\".
If you want to specify the order - and again even though asked, you have not answered why this is - then...guess what? YOU have to specify the order. Which I showed you how to do.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.