MikeHAdams
Programmer
I wrote a program that pulls data from various sources and creates a temporary table in an MBD file. I then open Word 2000 through code and open a Word document that has Mail Merge fields in it. I attach the MDB file as the datasource, set the Mail Merge Object to the SendToPrinter property and then invoke the "execute" method of the Word Mail Merge Object.
The problem is that when I invoke the "execute" method of the Mail Merge Object, a printer dialog box is opened and the user has to manually hit the "Ok" button to print the document. Since I am sending thousands of Word Mail Merged documents to the printer spool, it is unrealistic to require the user to manually hit the "Ok" button to print the currently active document each time it is displayed. I have tried unsuccessfully to use the Word "Dialogs" collection, the DoEvents function, and SendKeys statement. The problem seems to be that all flow of the program stop once the execute method is invoked, so no code is executed until after the print dialog box is closed.
I have little, to no experience sub-classing and hooking, which I believe is a solution to this problem. The other solution I though about but haven't tried is to created the Word objects with the "WithEvents" keyword. Is there anyway I can get the program to automatically print the document right after the Mail Merge "execute" method is invoked. Any solution, even sub-classing and hooking would be fine.
The problem is that when I invoke the "execute" method of the Mail Merge Object, a printer dialog box is opened and the user has to manually hit the "Ok" button to print the document. Since I am sending thousands of Word Mail Merged documents to the printer spool, it is unrealistic to require the user to manually hit the "Ok" button to print the currently active document each time it is displayed. I have tried unsuccessfully to use the Word "Dialogs" collection, the DoEvents function, and SendKeys statement. The problem seems to be that all flow of the program stop once the execute method is invoked, so no code is executed until after the print dialog box is closed.
I have little, to no experience sub-classing and hooking, which I believe is a solution to this problem. The other solution I though about but haven't tried is to created the Word objects with the "WithEvents" keyword. Is there anyway I can get the program to automatically print the document right after the Mail Merge "execute" method is invoked. Any solution, even sub-classing and hooking would be fine.