Prints an HTML (Hypertext Markup Language) document by supplying its HTML source code. The document will be printed exactly as you see it in Microsoft Internet Explorer.
Syntax
object.PrintHTMLDocFromSource(HTMLSource)
Where object evaluates to an ASP Printer object.
The PrintHTMLDocFromSource method has these arguments:
Part | Description |
HTMLSource | String expression containing the source code of the HTML document. |
Remarks
This method can be used to print an HTML document (page) by supplying its source code. For example, it can be used to print the HTML document that the user is currently viewing in his / her web browser. The document is printed using the user's Microsoft Internet Explorer printing features and settings.
The following VBScript example shows how to use this method to print the current HTML page that the user is currently viewing when he clicks on a button in the page:
Sub Print()
'Create the ASPPrinter object
Set Prn=CreateObject("ASPPrinterCOM.ASPPrinter")
'Get the entire HTML document source code
HTMLSource=document.documentElement.outerHTML
'Print the document using its source code
RetVal=Prn.PrintHTMLDocFromSource(HTMLSource)
'Clean up objects
Set Prn=Nothing
MsgBox "Print Completed Successfully!",,"ASP Printer COM"
End Sub
Note that by using this method, all object properties are ignored, whether set (or not) before calling this method. Also, setting the printer using the SetPrinter method will have no effect. The printer specified in the user's Microsoft Internet Explorer "Print Setup" will be used.
When you use this method to print an HTML document using its source code, the Windows Print Dialog will not be displayed before sending the document to the printer.
See also the PrintHTMLDocument and PrintHTMLFile methods.