Microsoft KB Archive/106250

{|
 * width="100%"|

Printing to a File Using the WordBasic FilePrint Statement

 * }

Q106250

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Windows versions 3.0, 3.1

-

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 Windows
The 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       Append The following command prints the contents of the current document to a file.

  FilePrint .PrToFileName = "C:\Temp\Filename.ext", .Type = 0, \ .PrintToFile = 1 If 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 Windows
The 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 Returns FilePrint .Type = 0, .PrintToFile = 1

End Sub Additional query words: 2.0 6.0 word6 winword winword2

Keywords : kbmacro kbprint kbmacroexample kbofficeprog

Issue type :

Technology :