Printing Word Documents based on Excel Sheet

GazNicki

Board Regular
Joined
Nov 30, 2010
Messages
56
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:

ABCD
1Document NameLocation# Copies
2Document 1.docxC:\Folder\30
3Document 2.docxC:\Folder6\50
4

<tbody>
</tbody>

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
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,003
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:

SpillerBD

Well-known Member
Joined
Jul 2, 2014
Messages
2,707
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 (?)
 

Watch MrExcel Video

Forum statistics

Threads
1,102,781
Messages
5,488,847
Members
407,658
Latest member
Arias610

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top