Printing Word Documents based on Excel Sheet

GazNicki

New Member
Joined
Nov 30, 2010
Messages
48
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
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,694
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 (?)
 

Forum statistics

Threads
1,081,976
Messages
5,362,514
Members
400,679
Latest member
alecalec202

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top