Excel

Print x copies of Word documents from Excel.

Ease of Use

Easy

Version tested with

2000, 2003 

Submitted by:

MOS MASTER

Description:

Programmatically print x copies of Word document from Excel. 

Discussion:

You want to print more then one copy of your Word document, and you want to do this from within Excel. 

Code:

instructions for use

			

Option Explicit Sub PrintWordDoc() Dim oWord As Object Dim sPath As String Dim iCnt As Integer 'Path to Cover.doc in same folder as workbook sPath = ThisWorkbook.Path & Application.PathSeparator & "Cover.doc" 'Ask copy count iCnt = Val(InputBox("How many copies", "Print Word doc", 1)) 'If any If iCnt >= 1 Then 'Create word application Set oWord = CreateObject(Class:="Word.Application") 'Open document sPath en printout wanted copies With oWord.Documents.Open(sPath) .PrintOut Background:=False, Copies:=iCnt .Close False End With 'Quit word application oWord.Quit False End If 'Clean up Set oWord = Nothing End Sub

How to use:

  1. Open an Excel workbook.
  2. Press Alt + F11 to open VBE.
  3. Insert-Module. (Insert -> module)
  4. Paste the code there in the window at right. (F7)
  5. Close VBE (Alt + Q or press the X in the top right hand corner).
  6. Save the file.
 

Test the code:

  1. From Excel, press Alt + F8 to open the macro dialog box.
  2. Select PrintWordDoc
  3. Click Run.
 

Sample File:

Print Word doc.zip 11.41KB 

Approved by mdmackillop


This entry has been viewed 192 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express