Intercept Print to File dialog box from VB and complete it.

Category:
System/API
Type:
Snippets
Difficulty:
Intermediate
Author:
Anonymous

Version Compatibility: Visual Basic 6

More information:
I wrote a report server in VB. The system sits all day long and starts Crystal Report reports on certain days. Some of the reports need to print on our mainframe printer. I created a printer on the report server computer that is type Print to file. Whenever a Crystal Report runs and is using this printer, the "Print to File" dialog box appears, and of course, no one is there to enter a filename and click OK. The attached code is run ever 30 seconds and if it sees the "Print to File" dialog box, it creates a filename and presses the ok button.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: