Interacting with other open windows
[Background] I have created a report in Access which I need to create PDF's for each individual record that feed the report (about 5,000). I have Acrobat Distiller which I can assign as the default printer. This will create a PDF file of the report when the report is sent to be printed.
[Problem] When I run my code (in a Module) to print, Distiller pops up a dialogue box asking for the path and filename to save the PDF file. Unfortunately, Distiller won't allow me to disable the dialogue box. So I have to sit there and hit the OK button 5,000 times.
[Question] I need code that can: a) detect open windows, including dialogue boxes, b)feed it an event (such as filling in the path and filename in the "save as" text box), and c) "hit" the "OK" or "submit" button.
Is this possible? Any insight will be greatly appreciated.
Re: Interacting with other open windows
Welcome to the Forums.
Do you have MS Spy++? If so you can use it to get the Window Class names
for the distiller print dialog box. Then you could use some APIs to click the
button for you.
You will need FindWindow, FindWindowEx, and SendMessage APIs.
Basically you will FindWindow for the Print dialog form window handle. Then
you FindWindowEx to get the handles for the cbo filepath/name, and handle
for the Ok button.
The class name for most dialog windows is "#32770" but verify with Spy++.
HTH
Re: Interacting with other open windows
Thanks for the reply Rob.
I don't have SPY++ on this machine, but have access to it and will install it and give it a try next week. Will post back results then.
Re: Interacting with other open windows
Ok, you can find the declarations/constants at allapi.net. Download their
API Viewer and API Guide. Search the Forums for more examples. Post if you
run into any issues.
HTH