The parent page is PrintUsingWord.
You can create an RTF document in Emacs, and if you have MS Word on your system you can automatically print it from Emacs at the same time.
Step 1 of the following technique creates a temporary RTF document, which will be printed and deleted in Step 2.
RTF is basically a plain Ascii text markup language. With a little reverse-engineering, you can create a “shell” RTF file into which you can place your text and then write out the RTF file containing your text. This is essentially what the code referenced above does:
ORIENT - a string: "P" causes the RTF to be in portrait orientation, any other string is landscape. LINE1 and LINE2 - two strings used for the header on each page. FILENAME - is a string for the fully qualified output file name. START and END - (optional) buffer positions if only part of the buffer is to be converted. By default the whole buffer is converted to RTF.
Step 2: Use Emacs to get MS Word to print your document.
VBScript is a very convenient tool for the Emacs programmer/user. Simple scripts can be used to access other Windows programs from Emacs. Provided that you have Word loaded on your system, this VBscript will print a specified file to a specified printer, then delete the document:
The following Elisp function call will execute this script:
(w32-shell-execute 1 vbs-wrd (concat "\"" docfile "\" \"" printer "\""))
vbs-wrd is an Elisp variable having the pathname of the script file. docfile is an Elisp variable having the pathname of the RTF file. printer is an Elisp variable having the name of the printer.