Printing Word Documents based on Excel Sheet

GazNicki

Board Regular
Joined
Nov 30, 2010
Messages
78
Hi

Bit of a shot in the dark here, but know that this is likely the best possible resource to ask.

My department admins have a lot of documents to print every week for various other departments, and printing these out is not only tedious and labour intensive - but open to errors and missed documents.

I was wondering if it was possible to use both VBA and Excel to take the risk of error, and the labour, out of the task.

Is it possible to have an Excel Spreadsheet listing the documents that need printing, with the folder location, and the number of copies - then having VBA work down the list opening, printing and closing each one?

For example:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Document Name[/TD]
[TD]Location[/TD]
[TD]# Copies[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Document 1.docx[/TD]
[TD]C:\Folder\[/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Document 2.docx[/TD]
[TD]C:\Folder6\[/TD]
[TD]50[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Is this something that can be done?

I would like to be able to update the list of documents if and when needed, and the VBA Button to go down the list until there is nothing left to process, printing the documents with the number of copies stipulated in the Worksheet.

At the moment, it is just an idea - so I haven't done much research on this. But if someone could tell me if this is possible, I would really appreciate it.

TIA

Gaz
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try here
https://stackoverflow.com/questions/1419829/print-a-word-document-without-opening-it-using-excel-vba

Put the loop to loop through your cells in this bit:
Code:
Set objDoc = objWord.Documents.Open("C:\Test\SomeDocument.docx")

' Step 3 -- in this case, print out the document without any prompts
objDoc.PrintOut

My Excel is tied up at the moment but there's probably a 'Copies:=' parameter

StackOverflow is a better resource for questions like that, as switching between Office apps using VBA has a lot of technical niggles.

One of which might be timing in this instance, if it takes word some time to print 50 copies, you might need to hard code a delay
Code:
For i = 1 to 5000: DoEvents: Next i
as Excel and Word are different processes and Excel won't wait for Word to finish, it just sends the command to the Word instance and ploughs on with the Excel VBA.
 
Last edited:
Upvote 0
From a recording of a printing in Word...
If you leave out the ActivePrinter it will print to the default or last printer used in Word.

Code:
ActivePrinter = "PH90000_011"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, [COLOR=#0000ff]Copies:=19[/COLOR], Pages:="", PageType:=wdPrintAllPages, _
         Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
         PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0

Replace Application with objDoc (?)
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top