Printing to a File Using the WordBasic FilePrint StatementLast reviewed: February 5, 1998Article ID: Q106250 |
The information in this article applies to:
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Word 6.0 for WindowsThe FilePrint statement in Word 6.0 for Windows includes parameters to allow you to print a document to a file. The FilePrint parameters for printing to a file are listed below.
.PrintToFile If 1, sends printer instructions to a file. .PrToFileName If PrintToFile = 1, this parameter specifies the path and filename of the file to print to. .AppendPrFile If PrintToFile = 1, this parameter specifies whether to overwrite or append to the file if it already exists: 0 (zero) Overwrite 1 AppendThe following command prints the contents of the current document to a file.
FilePrint .PrToFileName = "C:\Temp\Filename.ext", .Type = 0, \ .PrintToFile = 1If you later want to print the contents of the print file, use the following Copy syntax at the MS-DOS prompt:
copy /b <filename> LPT1:For more information on the MS-DOS COPY command, refer to pages 389-393 of the "Microsoft MS-DOS User's Guide and Reference" for MS-DOS version 5.0.
Word 2.x for WindowsThe FilePrint statement in Word 2.x for Windows does not include a parameter to indicate the print filename (.PrToFileName). To print the contents of the current document to a specific file without being prompted with the filename dialog box, use the SendKeys statement before the FilePrint command. For example:
Sub MAIN SendKeys "C:\Temp\Filename.ext" 'the filename to print to SendKeys "{Enter 2}" 'Send 2 ReturnsFilePrint .Type = 0, .PrintToFile = 1 End Sub |
KBCategory:
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |