Printing Word Documents based on Excel Sheet

GazNicki

New Member
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
 

Johnny C

Well-known Member
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
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 (?)
 

Some videos you may like

This Week's Hot Topics

  • Get External Data (long shot question!)
    This is likely a long shot but I am wondering if it is at all possible for Excel to somehow 'change' the contents of a URL that is being linked to...
  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • Cell Formatting
    Good Morning, I need to format a few different cells in the following manners: A1 has to always add a colon (:) after whatever is typed in by a...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • Workbook_Change stopped working !
    I am working on an app to speed up & automate processing of Credit Cards statements. After data is input from a CSV file, it is presented to the...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
Top