Jump to content

Inexplicable refusal of execution


jimfx
 Share

Recommended Posts

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

  • Developers

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

@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

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

  • Developers

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...