Print a Word document(s) without launching Word

T

Tony29

I have many Word documents that need to be printed and I don't want to have
to launch Word, open each file, print ... etc.

Is there a Word DOS style command or similar that will allow me to request a
print from a command line, with appropriate switches/parameters to allow me
to specify the scope and destination of the print (like the Print... dialogue
box).

In case you have a clever suggestion, I'll point out that I'm running a
document management style application in Access 2003 and if the user selects
and requests that a Word document be printed, I want to be able to do this
without the user fully launching Word and need to use the menus therein.
And just to make it more interesting, the user may wish to see a preview of
the Word document inside a the form that he is using in Access before
deciding to print the document.

Any suggestions?
 
G

Graham Mayor

The short answer to your question is no. Word has to be opened to print Word
documents. You should however be able to batch process the print run with a
macro to set up to apply the required print parameters e.g. the following
will print all the files in a folder and includes additional code to change
the printer - shown here as the Adobe PDF driver. You can run the macro from
the command line, but Word still has to open to print the documents.

Sub BatchPrint()
On Error GoTo err_FolderContents
Dim DocList As String
Dim DocDir As String
Dim sPrinter As String
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
.Title = "Select Folder containing the documents to be printed and click
OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
DocDir = fDialog.SelectedItems.Item(1)
If Right(DocDir, 1) <> "\" Then DocDir = DocDir + "\"
End With

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
DocList = Dir$(DocDir & "*.doc")
Do While DocList <> ""
Documents.Open DocList
'With Dialogs(wdDialogFilePrintSetup)
' sPrinter = .Printer
' .Printer = "Adobe PDF"
' .DoNotSetAsSysDefault = True
' .Execute
End With
ActiveDocument.PrintOut
'ActivePrinter = sPrinter
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
DocList = Dir$()
Loop
Application.ScreenUpdating = True
'ActivePrinter = sPrinter
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
' ActivePrinter = sPrinter
End Sub

http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top