Prints the current document using either the default print template or a custom print template.

C++ Information

Command group CGID_MSHTML (defined in mshtmhst.h)
Symbolic constant IDM_PRINT
User interface Optional. Set nCmdExecOpt to OLECMDEXECOPT_DODEFAULT or OLECMDEXECOPT_PROMPTUSER to display the print dialog. Set nCmdExecOpt to OLECMDEXECOPT_DONTPROMPTUSER to send the document directly to the current printer without invoking the dialog.
IOleCommandTarget::Exec parameters
pvaInVARIANT of type VT_BSTR, VT_I2, or VT_ARRAY. See Remarks. Can be set to NULL to use the Windows Internet Explorer default print template.
pvaOut Set to NULL.
Header file mshtmcid.h
Applies to IHTMLDocument2::execCommand, IHTMLDocument2::queryCommandEnabled, IHTMLDocument2::queryCommandIndeterm, IHTMLDocument2::queryCommandState, IHTMLDocument2::queryCommandSupported, IHTMLDocument2::queryCommandValue, IOleCommandTarget::Exec, IOleCommandTarget::QueryStatus.


If pvaIn is a VARIANT of type VT_BSTR, pvaIn specifies the path to a custom print template. If no template path is supplied, MSHTML uses the default print template.

If pvaIn is a VARIANT of type VT_I2, pvaIn can be set with the flags PRINT_DONTBOTHERUSER(0x01) and PRINT_WAITFORCOMPLETION(0x02) defined in mshtmhst.h. If 0 is specified, then the default behavior (show print dialog and do not wait for completion) occurs unless otherwise defined by the nCmdExecOpt parameter. The flags specified in the pvaIn parameter are given precedence over the OLECMDEXECOPT flags specified in the nCmdExecOpt parameter. For example, if both PRINT_DONTBOTHERUSER and OLECMDEXECOPT_PROMPTUSER are specified, PRINT_DONTBOTHERUSER has precedence and the print dialog is not displayed.

If pvaIn is a VARIANT of type VT_ARRAY, pvaIn specifies a SAFEARRAY containing (in the following order) a header BSTR, a footer BSTR, the address of an IStream pointer for a Microsoft Outlook Express header document, an alternate URLĀ  BSTR used for MSHTML in Outlook Express, and a DWORD containing flags.

Minimum Availability

Internet Explorer 5.5 and later.

See Also

IDM_PRINTPREVIEW, LayoutRect, DeviceRect, TemplatePrinter, HeaderFooter, dialogArguments, Beyond Print Preview: Print Customization for Internet Explorer 5.5, Print Preview 2: The Continuing Adventures of Internet Explorer 5.5 Print Customization