Hi All,
Here is an interesting PrintOut() scenario.
As expected, calling PrintOut() with no printerName set in the view printSettings results with the InfoPath form being printed out to the user's default printer.
To simplify the scenario. The same form has two views;
one view to print the whole form on A4 paper.
a second view to print parts of the form on bottle labels.
The slight complication is depending on the current user, the A4 and bottle label printers are different i.e. different departments.
A secondary data source provides the correct printer names - 1 for A4, 1 for bottle labels.
When either the A4 or label print button is pressed, WMI code is used to change the users default printer to the appropriate A4 or label printer.
This works with no problems and can be seen successfully changing the default printer in the Printer and Faxed control panel.
Now this is the problem! Whatever the user prints first e.g. labels, all subsequent print outs will be sent to the label printer despite the WMI code successfully changing the users default printer before the PrintOut() call.
To re iterate, should the user close the form and print A4 first. All subsequent PrintOut() calls will be sent to the A4 printer.
To really simplify this example. A test harness has been created which has a button control. The button control calls thisXDocument.PrintOut() in managed code. The first time this button is pressed the users current default printer is used to print out the form. Next i manually change the default printer in the Printer and Faxes control panel. The print button is pressed again and the form is printed out to the first / original default printer.
Furthermore analysis of thisXDocument.Solution.DOM.xml results with identical data. i.e. nothing changes between print outs.
Can someone shed any light onto why InfoPath appears to be storing the printer used in the first PrintOut() call and subsequently using this printer irrespective of any default printer changes???
Your help and time is really appreciated.
Kind regards
Scott