Is there a way to run a file through a print driver without opening the application?
Ex: run a .docx file, without opening word, and save it to file?
Is there a way to run a file through a print driver without opening the application?
Ex: run a .docx file, without opening word, and save it to file?
Since it is a .docx
-file Microsoft Word is probably the best program to do the task.
I would have a look at the [command line arguments] to Word:
Have a look at the following switches:
/q
, /n
, /mFilePrintDefault
and /mFileExit
(/q
and /n
explained in the page above, and /mXxxx
refers to macros. Have a look att google.)
Example:
WINWORD.EXE your_document.docx /mFilePrintDefault /mFileExit /q /n
The following page seems to explain how to convert it to PDF.
What you are looking for is called "headless start" of the program which needs to print. I know for sure that OpenOffice can do this. Basically, you need to start it and invoke a macro which will do the printing. Even more, you can print to a PDF, HTML, or anything else that Oo supports.
This negates the need for install of Microsoft Word and the cost of license, because OpenOffice is free.
If
Add something like this to normal.dotm:
Sub CmdPrint()
'
' CmdPrint Macro
'
'
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End Sub
Then call from the command line as detailed above, such as:
@echo off & setlocal
set ProjectFolder=%USERPROFILE%\Projects
set Project=MyTest
set DocType=docm
start winword "%ProjectFolder:\\=\%%Project%.%DocType%" /q /n /mCmdPrint mFileCloseOrExit
You might be interested in DocTo which will convert a word document to another file format, including pdf and XPS but does require Word on the machine.
For example
Docto -f "c:\docs\mydocument.docx" -o "c:\output" -t wdFormatPDF
Will output mydocument.docx to c:\output\mydocument.pdf as a pdf file.
If you are looking only for .docx silent printing then [aioobe] answer is the best. If you want a more generic silent print program that runs on Windows, use powershell or .NET and use the print verb. http://www.eggheadcafe.com/software/aspnet/30441939/how-to-suppress-printdialog-when-using-print-verb.aspx provides an example.
Hope this helps, if so +1 please :)