Print related procedures in class Document (Word VBA)

This page presents procedures from class Document related to the theme Print: FitToPages, PrintFormsData, PrintOut, PrintPostScriptOverText, PrintPreview and PrintRevisions

FitToPages

Decreases the font size of text just enough so that the document will fit on one fewer pages.

An error occurs if Word is unable to reduce the page count by one.

On Error GoTo errhandler 
ActiveDocument.FitToPages 
errhandler: 
If Err = 5538 Then MsgBox "Fit to pages failed"

PrintFormsData

True if Microsoft Word prints onto a preprinted form only the data entered in the corresponding online form.

ActiveDocument.PrintFormsData = True 
ActiveDocument.PrintOut

PrintOut

Prints all or part of the specified document.

Syntax : expression.PrintOut (Background, Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType, PrintToFile, Collate, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight)

ActiveDocument.PrintOut Range:=wdPrintCurrentPage

Arguments

The following arguments are optional

Background (Boolean) - Set to True to have the macro continue while Microsoft Word prints the document.

Append (Boolean) - Set to True to append the specified document to the file name specified by the OutputFileName argument. False to overwrite the contents of OutputFileName.

Range (Range) - The page range. Can be any WdPrintOutRange constant.

OutputFileName (String) - If PrintToFile is True, this argument specifies the path and file name of the output file.

From (WdPrintOutRange) - The starting page number when Range is set to wdPrintFromTo.

Possible Values are

wdPrintAllDocument The entire document.
wdPrintCurrentPage The current page.
wdPrintFromTo A specified range.
wdPrintRangeOfPages A specified range of pages.
wdPrintSelection The current selection.

To (WdPrintOutRange) - The ending page number when Range is set to wdPrintFromTo.

Possible Values are

wdPrintAllDocument The entire document.
wdPrintCurrentPage The current page.
wdPrintFromTo A specified range.
wdPrintRangeOfPages A specified range of pages.
wdPrintSelection The current selection.

Item (WdPrintOutItem) - The item to be printed. Can be any WdPrintOutItem constant.

Here you can find possible values for WdPrintOutItem.

Copies (Long) - The number of copies to be printed.

Pages (Pages) - The page numbers and page ranges to be printed, separated by commas. For example, "2, 6-10" prints page 2 and pages 6 through 10.

PageType (WdPrintOutPages) - The type of pages to be printed. Can be any WdPrintOutPages constant.

Possible Values are wdPrintAllPages - All pages, wdPrintEvenPagesOnly - Even-numbered pages only, wdPrintOddPagesOnly - Odd-numbered pages only.

PrintToFile (Boolean) - True to send printer instructions to a file. Make sure to specify a file name with OutputFileName.

Collate (Boolean) - When printing multiple copies of a document, True to print all pages of the document before printing the next copy.

ActivePrinterMacGX - This argument is available only in Microsoft Office Macintosh Edition. For additional information about this argument, consult the language reference Help included with Microsoft Office Macintosh Edition

ManualDuplexPrint (Boolean) - True to print a two-sided document on a printer without a duplex printing kit. If this argument is True, the PrintBackground and PrintReverse properties are ignored. Use the PrintOddPagesInAscendingOrder and PrintEvenPagesInAscendingOrder properties to control the output during manual duplex printing. This argument may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

PrintZoomColumn (Long) - The number of pages you want Word to fit horizontally on one page. Can be 1, 2, 3, or 4. Use with the PrintZoomRow argument to print multiple pages on a single sheet.

PrintZoomRow (Long) - The number of pages you want Word to fit vertically on one page. Can be 1, 2, or 4. Use with the PrintZoomColumn argument to print multiple pages on a single sheet.

PrintZoomPaperWidth (Long) - The width to which you want Word to scale printed pages, in twips (20 twips = 1 point; 72 points = 1 inch).

PrintZoomPaperHeight (Long) - The height to which you want Word to scale printed pages, in twips (20 twips = 1 point; 72 points = 1 inch).

PrintPostScriptOverText

True if PRINT field instructions (such as PostScript commands) in a document are to be printed on top of text and graphics when a PostScript printer is used.

The PrintPostScriptOverText property controls whether postscript code is printed in a converted Microsoft Word for Macintosh document. If the document contains no PRINT fields, this property has no effect.

ActiveDocument.PrintPostScriptOverText = True 
ActiveDocument.PrintOut

PrintPreview

Switches the view to print preview.

In addition to using the PrintPreview method, you can set the PrintPreview property to True or False to switch to or from print preview, respectively. You can also change the view by setting the Type property for the View object to wdPrintPreview.

If Application.PrintPreview = False Then 
 ActiveDocument.PrintPreview 
End If

PrintRevisions

True if revision marks are printed with the document. False if revision marks aren't printed (that is, tracked changes are printed as if they'd been accepted).

With ActiveDocument 
 .PrintRevisions = False 
 .PrintOut 
End With