JessicaZ Posted October 20, 2014 Posted October 20, 2014 I'm new with AutoIt. I want to automate the process of printing a Microsoft word file to prn file. What I have: 1.A Printer installed ($PrinterName) port to FILE: 2. Code I used: _Word_DocPrint ( $oDoc, 1, 1, -1, 1, $PrinterName, 0) ;($b_Background = 1 in order to continue) ;After call Word_DocPrint, MS Word will show "Print to file" window, and ask file name. WinWaitActive("Print to file") ControlSetText ( "Print to file", "", "ID:1001", "C:TempNEW-FILE.prn", 0 ) ;ID:1001 is text edit box ControlClick( "Print to file", "", "[CLASS:Button; TEXT:OK; INSTANCE:7]") When I run these in debug mode, it paused at _Word_DocPrint, not even continue run other lines. Then I tried with another DOS command line to print: Dim $cmd = 'winword.exe Default.doc /mFilePrintDefault' Run ($cmd) Opt("WinTitleMatchMode", 2) WinWait ("Print to file", "", 2) ControlCommand ( "Print to file", "", "ID:1001", "GetSelected", "" ) ControlSetText ( "Print to file", "", "ID:1001", "C:TempNEW-FILE.prn", 0 ) WinWaitActive("[CLASS:Button; TEXT:OK; INSTANCE:7]") ControlClick( "Print to file", "", "[CLASS:Button; TEXT:OK; INSTANCE:7]") Although it goes to every command lines to the end, but it doesn't save any file and 'ok' quit the dialog window. Something wrong in my code. Any suggestions please....
Jfish Posted October 21, 2014 Posted October 21, 2014 This might help. http://msdn.microsoft.com/en-us/library/bb237242%28v=office.12%29.aspx OutputFileName Optional Variant If PrintToFile is True, this argument specifies the path and file name of the output file. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now