jimfx Posted February 15, 2009 Share Posted February 15, 2009 Hello, I am using a combination of Excel VB and AutoIT for printing invoices from excel to a PDF file. The invoice is being printed as follows: In excel a (VB) macro is being executed, which (among other things) will pre-select the PDF printer. Then the AutoIT file is being executed via this command line in VB: Dim Myapp Myapp = Shell("C:\Autoit\printpdf.exe", 1) The (autoit) printpdf.exe file contains following code: Sleep (100) $bak = ClipGet() Sleep (100) Opt("WinTitleMatchMode", 3) WinActivate("Microsoft Excel - invoice") sleep (100) Send("^p") WinWaitActive("Print") Send("{TAB}{ENTER}") Opt("WinTitleMatchMode", 2) WinWaitActive("CIB pdf brewer","") Send("i") WinWaitActive("Save as","") Send ($bak) Opt("WinTitleMatchMode", 2) WinWaitActive("Adobe Reader") Etc. Etc. The problem: sometimes the Autoit code is not being executed, but it hangs. You have to go to the windows systray to exit autoit, and start over again. Where does it go wrong? PS it usually happens when the computer has been idle for a while. After the first unsuccesful execution, the other pdf-prints go without problem Many thanks in advance Jim Link to comment Share on other sites More sharing options...
Developers Jos Posted February 15, 2009 Developers Share Posted February 15, 2009 Add this line to allow you to determine where it is hanging: Opt("TrayIconDebug", 0) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Manjish Posted February 15, 2009 Share Posted February 15, 2009 @jos a good suggestion.. I generallay use msgboxes to identify what stage its hanging at and why.. [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
jimfx Posted February 15, 2009 Author Share Posted February 15, 2009 Thanks Jos, I think I know the problem (but no solution) When selecting the PDF-printer for the first time, the computer needs some time. I think there it goes wrong. I could add a 4 or 5 seconds sleep, but is there a better way? Link to comment Share on other sites More sharing options...
BrettF Posted February 15, 2009 Share Posted February 15, 2009 This Excel UDF has printing support.http://www.autoitscript.com/forum/index.ph...02&hl=excelMaybe more so what you are after? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Developers Jos Posted February 15, 2009 Developers Share Posted February 15, 2009 Thanks Jos,I think I know the problem (but no solution)When selecting the PDF-printer for the first time, the computer needs some time. I think there it goes wrong. I could add a 4 or 5 seconds sleep, but is there a better way?Can't you do some WinWait() or "IsEnabled" check for a control using ControlCommand() ?Normally something changes at the time the GUI is really available.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
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