Article ID: 194306 - View products that this article applies to.
This article was previously published under Q194306
This article describes how to use OLE automation from Visual FoxPro to Microsoft Word for Windows 97 to print a document duplex.
Since the dialog box that sets duplex printing is part of the printer setup, there is not a direct command that you can issue that causes a document to print duplex. However, there are three ways that do work allowing you to print documents duplex.
The printer used in this test is a Hewlett-Packard LaserJet printer, which supports duplex printing.
Method 1Use the PRINT field in Word to send the printer escape code that puts the printer in duplex mode. The following code demonstrates this:
This code does not work if the Word document contains mixed orientation, that is portrait and landscape sections.
Note This code only works with the Service Release-1 (SR-1) for Word 97. Prior versions of Word 97 do not duplex print using this code.
For the Word document to print correctly, it should not contain headers or footers on every page. However, it should print duplex if the document is setup to have a different first page header or footer only and the PRINT field is inserted on the first line of the header followed by a carriage return.
Method 2Use the SendKeys command to send keystrokes to Word, which simulates using keystrokes to open the Print dialog box.
In the Sendkeys command, the % sign represents using the ALT key to access Windows menus. The INKEY() command allows Word to process the keystrokes before Visual FoxPro for Windows processes the Quit. This may need to be adjusted up, down, or removed depending on the application.
To use Sendkeys, Word must be visible, not minimized, since the keystrokes must go to an active window. You can move Word off screen by using the AppMove command, so that Word does not show, but the dialog box still displays. Also, using Sendkeys can be disconcerting because the menus and dialog boxes open and process as if you were in Word and pressed the ALT+F keys to open the File menu.
Method 3Create a Word macro that issues the Sendkeys. If the macro is named SendKey, then run the macro from Visual FoxPro using the following command:
The minimum code for the Word macro to send the keys for duplex printing follows:
Note Please see the Note in Method 2 for problems you may encounter using SendKeys.
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
135569For additional information about how to obtain Word for Windows 97 Service Release 1, click the following article number to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/135569/ )PCL escape codes to use with the PRINT field
172475Microsoft Word Visual Basic Help
(http://support.microsoft.com/kb/172475/ )How to obtain and install MS Office 97 SR-1
(c) Microsoft Corporation 1998. All Rights Reserved. Contributions by Dean Christopher, Microsoft Corporation.
Contact us for more help
Connect with Answer Desk for expert help.