Macro to Print a Word document from Excel

Aleksandra

New Member
Joined
Sep 30, 2010
Messages
1
Hi All, I'm trying to create a button which prints multiple external documents (some word and some pdf) using a Macro in Excel. I've begun a Macro, but I don't know enough to see what I've done wrong...

Please explain what I need to Print these external documents, even one at a time. Here's what I attempted:

Sub PrintTitleWd()
'
' PrintTitleWd Macro
'
Dim MyWd As Word.Application
Set MyWd = CreateObject(Word.Application)

With MyWd
.Visible = True
Application.PrintOut Filename:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End With
MsgBox "Quit this Application"
MyWd.Quit
Set MyWd = Nothing
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
If you read your code there is no reference to actually opening the file.

The code below will print out the file.

Code:
Dim MyWd As Word.Application
Set MyWd = CreateObject(Word.Application)

With myWD
    
    .Visible = True
    .Documents.Open ("C:\Temp.doc")
    .PrintOut
    .Quit

End With

Hope it helps
 
Upvote 0

Forum statistics

Threads
1,215,877
Messages
6,127,500
Members
449,385
Latest member
KMGLarson

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