The information in this article applies to:
SUMMARY
Printing either a range or selection of pages in a Word for Windows
document from Visual FoxPro for Windows using OLE automation requires
additional parameters for the PrintOut method of Word for Windows 97 or the
FilePrint command in Word for Windows 95.
MORE INFORMATIONThe code samples in this article are written to run exclusively with a particular version of Word. The examples for Word for Windows 95 were written to work with both Visual FoxPro for Windows versions 3.0b, 5.0a, and 6.0. The Word 97 example works only with Visual FoxPro for Windows versions 5.0a with Service Pack 2 installed and 6.0. If the code is used with any other version of Word or Visual FoxPro for Windows, the following OLE error may occur: The Range parameter accepts five valid values. Therefore, unless the Range parameter is properly set, Word will not print. The valid Range values are listed below with a description of the their action:
For more information on the FilePrint command in Word 95 and PrintOut
command in Word 97, see the Word for Windows documentation. The format of
the Word 97 PrintOut method and the Word 95 FilePrint command are listed
below:
In the code examples below a Word document named Testdoc.doc is used that
contains at least 10 pages.
Printing Contiguous Range of pagesThere are two ways to print a contiguous range of pages using the Range parameter. Both methods depend on the value of Range. For instance, if the Range is set to 3, then set the From and To parameters. If the Range is 4, use the Pages parameter. Both methods are discussed below. In each code example, the FilePrint and PrintOut commands are shown using both variables and the explicit values for the arguments. This provides a better representation of the positions these arguments will take in the statement. The command using variables is commented out.Method 1: Range Argument Set to 3With the Range set to 3, the From and To parameters need to set for both the PrintOut method in Word 97 and FilePrint command in Word 95.For example, to print pages 4 through 8 of Testdoc.doc use the following Code. NOTE: This works with Word 95 and Visual FoxPro for Windows versions 3.0, 5.0, and 6.0.
NOTE: This works with Word 97 and Visual FoxPro for Windows version 5.0a
with Service Pack 2 and 6.0:
Method 2: Range Argument Set to 4Assign 4 to the Range argument, then assign the pages to be printed to the Pages argument. To print pages 4 through 8, the Pages argument would be "4- 8."NOTE: This works with Word 95 and Visual FoxPro for Windows versions 3.0, 5.0, and 6.0:
NOTE: This works with Word 97 and Visual FoxPro for Windows version 5.0a
with Service Pack 2 and 6.0:
Printing Non-Contiguous Range of PagesTo print non-contiguous pages, set the Range parameter to 4 and the Pages parameter to the pages to print. For example, to print page 2 and then pages 6 through 9, the Pages argument would be "2,6-9." The Pages parameter is set the same for both Word 95 and Word 97.NOTE: This works in Word 95 and Visual FoxPro for Windows versions 3.0, 5.0, and 6.0:
NOTE: This works with Word 97 and Visual FoxPro for Windows version 5.0a
with Service Pack 2 and 6.0:
(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Dean
Christopher, Microsoft Corporation
REFERENCESMicrosoft Word Visual Basic Help Additional query words:
Keywords : kbcode kbinterop kbAutomation kbVFp300 kbVFp500 kbVFp600 kbVS97 kbVS97sp2 kbWord |
Last Reviewed: August 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |