Hello all,
I've done a bit of playing with win32ole and thought
I would share a little piece of code with you.
This opens a file dialog onto your "My Documents"
folder and lets you select a document for MS Word
to print (which it then does).
Cheers,
Hal
require "win32ole"
Dir.chdir "C:\\My Documents"
dlg = WIN32OLE.new("MSComDlg.CommonDialog");
# Set file filter
dlg.filter = "Word documents (*.doc)|*.doc" +
"|All Files(*.*)|*.*"
dlg.filterIndex = 1
# Set MaxFileSize
dlg.maxFileSize = 128
file = ""
dlg.showOpen()
# Retrieve file + path
file = dlg.fileName
exit if file == ""
# Have a filename now...
word = WIN32OLE.new "Word.Application"
word.visible = false
# Open the desired file
word.documents.open file
word.options.printBackground = false
word.activeDocument.printOut
word.quit